How to organize files properly in Python projects
<p>I am having some difficulty with projects in Python. This is with reference to <a href="http://learnpythonthehardway.org/book/ex48.html" rel="nofollow">Qn 48</a> of <a href="http://learnpythonthehardway.org/" rel="nofollow">Learn Python the Hard Way</a>.</p>

<p>The line of the tester <code>lexicon_tests.py</code> that's throwing up a problem:</p>

<pre><code>from ex48 import lexicon
</code></pre>

<p>The error I am seeing is:</p>

<pre><code>ImportError: no module named ex48
</code></pre>

<p>I wonder if this is because I haven't organized my files properly within the projects folder: I have a folder named <code>ex48</code>, subfolders of which include <code>tests</code> and <code>lexicon</code>. Within <code>lexicon</code>, I have the file <code>lexicon.py</code>. Within <code>tests</code>, I have the file <code>lexicon_tests.py</code></p>

<p>Is there an error in the above organization?</p>

<p>EDIT: Posting the code here -</p>

<p>In /ex48, I have setup.py</p>

<pre><code>try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'My Project',
    'author': 'MyName',
    'url': 'URL to get it at.',
    'download_url': 'Where to download it.',
    'author_email': 'My email.',
    'version': '0.1',
    'install_requires': ['nose'],
    'packages': ['ex48'],
    'scripts': [],
    'name': 'projectname'
}

setup(**config)
</code></pre>

<p>in /ex48/lexicon, I have lexicon.py</p>

<pre><code>class lexicon:
    @staticmethod

    def scan(string):   

        direction = ['north', 'south', 'east', 'west', 'down', 'up', 'left',          'right', 'back']
        verbs = ['go','stop','kill','eat']
        stop = ['the','in', 'of', 'from', 'at','it']
        nouns = ['door', 'bear', 'princess', 'cabinet']

        words = string.split()

        result = []
        for word in words:
                if word in direction:
                result.append(('direction',word))
</code></pre>

<p>and so on . .  . with <code>return result</code> at the end. All the environment variables have been correctly added. The error I see is <code>ImportError</code> with the name lexicon.</p>
