del(instance.attr) -- no attribute
Erik Max Francis
max at alcyone.com
Sun Sep 1 17:43:11 EDT 2002
Lee Harr wrote:
> Is this a bug?
> >>> class C:
> ... a = 1
> >>> c = C()
> >>> c.a
> >>> del(c.a)
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: C instance has no attribute 'a'
> >>> hasattr(c, 'a')
> I can see that maybe del(c.a) should not be allowed to delete
> the attribute, but I think the error message is misleading.
Well, to its credit, it _does_ say that the _instance_ doesn't have the
attribute, which is precisely what the problem is.
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
Church / http://www.alcyone.com/pyos/church/
A lambda calculus explorer in Python.
More information about the Python-list