AttributeError in 2.0

echuck at mindspring.com echuck at mindspring.com
Wed Oct 11 21:29:20 EDT 2000


The "What's New" document at:
  http://starship.python.net/crew/amk/python/writing/new-python/

says:
  The AttributeError exception has a more friendly error message, whose
text will be something like 'Spam' instance has no attribute 'eggs'.
Previously the error message was just the missing attribute name eggs,
and code written to take advantage of this fact will break in 2.0.

However:
>python
Python 2.0c1 (#7, Oct  9 2000, 18:44:43) [MSC 32 bit (Intel)] on win32
>>> d = {}
>>> d.foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: foo

I was expecting:
  AttributeError: Dictionary has no attribute 'foo'

Which is obvious in this case, but not alway so in a real program.

A little more experimentation shows that this does work for instances,
but not other things. Does it have to be that way or can this be
expanded?

-Chuck


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list