Michael Tobis <[EMAIL PROTECTED]> wrote:
> Still a bit confused actually. Any explanation of the following?
I believe the problem you're having is with WHEN a name is looked up --
which tends to be 'as late as possible, but no later'.
> def getf(method,name):
> def f(self, *a, **k): return m
Still a bit confused actually. Any explanation of the following?
mt
def getf(method,name):
def f(self, *a, **k): return method(self.val, *a, **k)
f.func_name = name
return f
class myint(object):
def __init__(self, val):
self.val = int(val)
for spec in 'str repr has
Thanks! Only a minor correction: the last line should be
_setdelegate(myint, int,'__%s__' % spec)
The business with f.func_name struck me as unnecessary, but I was quite
wrong.
This was an interesting exercise for me. Thanks.
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Michael Tobis <[EMAIL PROTECTED]> wrote:
> I'd appreciate an explanation of why this doesn't work and any
> workarounds.
Special methods are looked up (for their automatic use) on the type, not
the instance. The workaround is therefore to set them on the type, too:
> class myint(object):
>
>