python import error
Michael Torrie
torriem at gmail.com
Wed Dec 11 00:02:34 EST 2013
On 12/10/2013 09:25 PM, Michael Torrie wrote:
> On 12/10/2013 08:56 PM, smilesonisamal at gmail.com wrote:
>> Traceback (most recent call last):
>> File "aaa.py", line 5, in <module>
>> from ccc.ddd import sss
>> ImportError: No module named ccc.ddd
>>
>> directory structure as follows:
>>
>> ccc
>> |
>> ddd
>> |
>> aaa.py
>> sss.py
>
> This is because directories have no inherent meaning to python. A
> module is normally a file. If you want to group a bunch of files
> together you have to use a package. See the docs on how to make a
> package. But the namespace structure within a package isn't based on
> the directory tree either. It's usually set up by __init__.py within
> the package which imports modules defined in the package into the
> namespace.
>
> http://docs.python.org/3/tutorial/modules.html#packages
>
> Hope this helps.
>
I didn't quite get that right. Follow John's advice on __init.py__ and
you'll have what you want I think.
More information about the Python-list
mailing list