Message bug?
Andy Gimblett
gimbo at ftech.net
Wed Mar 20 11:33:40 EST 2002
On Wed, Mar 20, 2002 at 04:15:38PM +0000, Dale Strickland-Clark wrote:
> Would I be right in thinking that this message quite what the
> developer intended?
>
> AttributeError: 'module' object has no attribute 'work'
>
> I have no module called 'module'.
>
> Python 2.2 on Win2K.
I don't think you would be right, ie that message is probably
perfectly correct, you're just misinterpreting it.
The error message doesn't imply that you have a module called
'module'. It implies that you're trying to access the 'work'
attribute of some object which _is a module_, but whose name is not,
alas, reported here.
Here's a demonstration using python2.3. I import some module, then
try to access a non-existent attribute called "foo", and get the same
error as you.
Python 2.3a0 (#1, Mar 19 2002, 14:46:42)
[GCC 2.95.4 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import struct
>>> struct.foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'foo'
Interestingly, the error message in 2.1 is somewhat more helpful in
that it tells us which module we're trying to acces:
Python 2.1.2 (#1, Mar 14 2002, 10:30:29)
[GCC 2.95.4 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import struct
>>> struct.foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'struct' module has no attribute 'foo'
Does anyone know why this changed? Even so, if you have a traceback
from a running program that'll probably tell you the module name.
By the way, it's almost always a good idea to post actual code (and/or
a full traceback, if talking about exceptions). That way we might
actually be able to tell you _exactly_ what's wrong. :-)
Hope this helps,
Andy
--
Andy Gimblett - Programmer - Frontier Internet Services Limited
Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/
Statements made are at all times subject to Frontier's Terms and
Conditions of Business, which are available upon request.
More information about the Python-list
mailing list