Hi all,

From what I understand about the lookup semantics of instances and classes, the following is expected:

>>> class A(object): pass
...
>>> A.__module__
'__main__'
>>> A().__module__
'__main__'

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:

>>> A.__name__
'A'
>>> A().__name__
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?

Best Regards,
Nicodemus.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to