AttributeError: module object has no attribute
Nikhil
mnikhil at gmail.com
Tue May 20 14:01:15 EDT 2008
Peter Otten wrote:
> Nikhil wrote:
>
>> I have recently written a small module. When I import the module, I
>> always get the error
>>
>>
>> only when I do
>>
>> >>> from local.my.module import *
>>
>> --
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> AttributeError: 'module' object has no attribute '/xyz/py/file'
>> ---
>>
>>
>> but when I do the below, I do not get any error.
>>
>> --
>> >> import local.my.module
>> >>
>> --
>>
>> Any ideas on what could be wrong?
>
> Are you abusing the __all__ attribute?
>
> $ cat tmp.py
> __all__ = ['/xyz/py/file']
>
> $ python -c "from tmp import *"
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> AttributeError: 'module' object has no attribute '/xyz/py/file'
>
> Peter
Hi Peter,
Yes, I am. Is there any reason not to?
basically, since this is implemented in the module, I have to export it
since the caller to the function in the module is responsible for
ensuring he has enough proper permissions to read the file.
Thanks,
Nikhil
More information about the Python-list
mailing list