Steven D'Aprano wrote:
I think I need to see an actual working demonstration, because as far as I can see, type(obj) returns obj.__class__.

Nope:

>>> class C(object):
...  def f(self):
...   return "Surprise!"
...  __class__ = property(f)
...
>>> c = C()
>>> type(c)
<class '__main__.C'>
>>> c.__class__
'Surprise!'

It appears that type() bypasses the attribute access
mechanism and goes straight for the actual type.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to