Message bug?

Dale Strickland-Clark dale at riverhall.NOTHANKS.co.uk
Wed Mar 20 11:43:55 EST 2002


"A.M. Kuchling" <akuchlin at ute.mems-exchange.org> wrote:

>In article <99dh9us1b4d8r9u7p5ltt41g34vlun4kjj at 4ax.com>, Dale Strickland-Clark wrote:
>> AttributeError: 'module' object has no attribute 'work'
>> 
>> I have no module called 'module'. 
>
>It's printing the type of the offending object:
>
>>>> a.foo
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: 'int' object has no attribute 'foo'
>>>>
>
>I suppose the single quotes are a bit confusing; maybe they should
>just be removed.  Classes do better:
>
>>>> class C: pass
>...
>>>> c=C()
>>>> c.foo
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: C instance has no attribute 'foo'
>
>Reasonable.  But new-style classes bring the single quotes back:
>
>>>> class D(object): pass
>...
>>>> d=D()
>>>> d.foo
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: 'D' object has no attribute 'foo'

Oh. I see.

Hmm, that's fair enough, I guess. It would be nice to include the
module name, though. Use repr(modulename) to print it, maybe. That
would give a bit more info.

Thanks.
--
Dale Strickland-Clark
Riverhall Systems Ltd



More information about the Python-list mailing list