importing a method
Alex Martelli
aleax at mail.comcast.net
Mon Nov 28 22:01:59 EST 2005
Martin Miller <ggrp1.20.martineau at dfgh.net> wrote:
> I'd like to point out to the OP that using a function's __get__ method
> this way only works with new-style classes and their instances...not
> with the example in the shown in original post.
Uh, why not?
>>> class old: pass
...
>>> def f(self): print self
...
>>> o=old()
>>> o.z = f.__get__(o, old)
>>> o.z
<bound method old.f of <__main__.old instance at 0x53d78>>
>>>
There's a million reason to avoid using old-style classes in new code,
but it doesn't seem to me that this is one of them. What am I missing?
Alex
More information about the Python-list
mailing list