On 12/17/2013 02:35 AM, Gregory Ewing wrote:
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!'
I believe the proxying info comes into play with __class__.__name__:
--> class Test:
... pass
...
--> t = Test()
--> type(t)
<class '__main__.Test'>
--> t.__class__
<class '__main__.Test'>
--> t.__class__.__name__
'Test'
--> t.__class__.__name__ = 'some_proxy'
--> t.__class__.__name__
'some_proxy'
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list