473,898 Members | 3,123 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6135
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>
AttributeErro r: '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 "implemente d 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>
AttributeErr or: '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>
AttributeErro r: '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 "implemente d 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
2485
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 __init__and defined a __del__ method to clean up resources. I then discovered asimilar problem in the shelve module. This led me to two importantdiscoveries: 1. Attributes defined in __init__ after an error is raised will not be apart of the...
2
9540
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
2060
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__ = <bound method AttributeError.__getitem__ of <exceptions.AttributeError instance at 0x8187984>> __init__ = <bound method AttributeError.__init__ of <exceptions.AttributeError instance at 0x8187984>> __module__ = 'exceptions'
4
7696
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 "/usr/local/bin/SquidClamAV_Redirector.py", line 573, in ? redirector = SquidClamAV_Redirector(config) File "/usr/local/bin/SquidClamAV_Redirector.py", line 145, in __init__
2
3436
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 script is described at http://www.paul.sladen.org/toys/samsung-yh-925/ I'm getting errors and hoping someone could give me some hints, for I have no python background.
2
2051
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 the object to list the user the known attributes.
3
2813
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 the class Time in the target module. The module (mytime.py) sits in a package hierarchy such as the following "packageA.packageB.mytime", and imports the Python module "time" like this: "import time" In another module outside of both packages...
4
23472
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 "C:\Python25\lib\site-packages\win32com\client\__init__.py", line 12, in <module> import dynamic, gencache, pythoncom File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py",
1
6399
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
11254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10853
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10480
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8034
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7187
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.