Can anyone explain this behaviour (class attribute vs instance lookup)
Bruno da Silva de Oliveira
nicoddemus at gmail.com
Tue Mar 7 13:16:46 CET 2006
>From what I understand about the lookup semantics of instances and classes,
the following is expected:
>>> class A(object): pass
IOW, if an attribute is not found in the instance, it is looked-up in class,
and if found, returned. Then, I was pluzzed by this behaviour:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'A' object has no attribute '__name__'
It seems that '__name__' is being treated differently somehow. I guess this
involves the descriptor machinery, but I don't know the internals of the
new-class completely to explain the above behaviour in detail. Can anyone
explain precisely the above semantics?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list