new.instancemethod - how to port to Python3

Arnaud Delobelle arnodel at gmail.com
Sun Apr 7 06:41:46 EDT 2013


On 7 April 2013 10:50, Helmut Jarausch <jarausch at skynet.be> wrote:
> Hi,
>
> I'm trying to port a class to Python3.3 which contains
>
> class  Foo :
>     ....
>     def to_binary(self, *varargs, **keys):
>        ....
>
>     ....
>     self.to_binary = new.instancemethod(to_binary, self, self.__class__)

`self` isn't bound in this lexical scope (the class scope).  Or is
your indentation incorrect?  However, if this statement was within the
`to_binary` method, then `to_binary` wouldn't be bound so I can't make
a reasonable guess.

>     # Finally call it manually
>     return apply(self.to_binary, varargs, keys)
>
[...]

-- 
Arnaud



More information about the Python-list mailing list