2017-04-20 15:55 GMT-05:00 Lele Gaifax <l...@metapensiero.it>:

> Does
>
>     underlying = getattr(SomeOtherClass, a)
>     def _meth(self, *args, _underlying=underlying):
>         return _underlying(self._instance, *args)
>
> help?
>

Hi, Lele. Long time no chat...

I thought of that, but with _underlying declared after *args I get a syntax
error in Python 2. If I move it in front of *args, the syntax error
disappears, but it gets interpreted as a the first argument of the method.
So if I call

obj.m1(4000)

it tries to call

4000(self._instance, *args)

Maybe functools.partial would be useful in this scenario, where I'm passing
the unbound method object to be called as a parameter. I'll have to play
around with that.

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

Reply via email to