Metaclass conundrum - binding value from an outer scope
skip.montanaro at gmail.com
Fri Apr 21 08:31:41 EDT 2017
2017-04-20 15:55 GMT-05:00 Lele Gaifax <lele at metapensiero.it>:
> underlying = getattr(SomeOtherClass, a)
> def _meth(self, *args, _underlying=underlying):
> return _underlying(self._instance, *args)
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
it tries to call
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.
More information about the Python-list