473,287 Members | 3,240 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

AttributeError: module object has no attribute

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?
Thanks in advance.

Nikhil
Jun 27 '08 #1
4 6084
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
Jun 27 '08 #2
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
Jun 27 '08 #3
On Tue, 20 May 2008 23:31:15 +0530, Nikhil wrote:
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'

Yes, I am. Is there any reason not to?
That your module raises the `AttributeError` and is broke is not reason
enough!? :-)
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.
What do you mean by "implemented in the module"? `__all__` is for names
that live in the module's namespace -- '/xyz/py/file' isn't even a legal
identifier name in Python!

Ciao,
Marc 'BlackJack' Rintsch.
Jun 27 '08 #4
Marc 'BlackJack' Rintsch wrote:
On Tue, 20 May 2008 23:31:15 +0530, Nikhil wrote:
>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'
Yes, I am. Is there any reason not to?

That your module raises the `AttributeError` and is broke is not reason
enough!? :-)
>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.

What do you mean by "implemented in the module"? `__all__` is for names
that live in the module's namespace -- '/xyz/py/file' isn't even a legal
identifier name in Python!

Ciao,
Marc 'BlackJack' Rintsch.
Okay.. thanks :-)

I removed the entry from __all__, and I earlier assumed the module to
break, but it did not. Thanks again :-)

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: seth | last post by:
Last week I encountered an AttributeError in my unit tests that I wasn'table to catch with an "except AttributeError" statement. The problem stemmed from a class that raised an error inside...
2
by: dont bother | last post by:
Hey, I am trying to run the following example from diveintopython import urllib sock = urllib.urlopen("http://diveintopython.org/") htmlSource = sock.read() sock.close() print htmlSource
0
by: Erlend Fuglum | last post by:
I have tried and tried, but cannot figure out the source of the following error: AttributeError: 'module' object has no attribute 'menyHMTL' __doc__ = 'Attribute not found.' __getitem__ =...
4
by: adrian | last post by:
I get those errors when I run: /usr/local/bin/SquidClamAV_Redirector.py -c /etc/squid/SquidClamAV_Redirector.conf ################## Traceback (most recent call last): File...
2
by: rsd | last post by:
Hi, I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux. To do that I need to run http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py script, the idea behind the...
2
by: Thomas Guettler | last post by:
Hi, how can you list the attributes of an object if you catch an AttributeError? I couldn't find a reference in the exception object, which points to the object. I want to call dir() on...
3
by: Juha S. | last post by:
I'm getting a "AttributeError: 'module' object has no attribute 'clock'" when importing a module from within two packages related to the line: "self.lastTime = time.clock()" in the __init__() of...
4
by: black_13 | last post by:
what does this error mean? i am trying to use mark hammonds win32 package. Traceback (most recent call last): File "aui2.py", line 11, in <module> import win32com.client File...
1
by: =?iso-8859-1?q?KLEIN_St=E9phane?= | last post by:
Hi, I'm on Ubuntu 8.04.1 I've installed lxml with easy_install lxml command. Now, when I load etree I've this error : $ python Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.