On 18.05.2012 15:10, Steven D'Aprano wrote:
> Here's one way:
>
> import types
> class K(object):
> def _dispatcher(self, name, *args):
> print "called from", name, args
> def __init__(self):
> setattr(self, 'foometh',
> types.MethodType(
>
On Fri, 18 May 2012 14:14:33 +0200, Johannes Bauer wrote:
> Hi group,
>
> I'm trying to dynamically add methods to a class at runtime. What I
> would like to do is have them all delegated to one common function which
> is called with the name of the function as first parameter. I.e.:
[...]
Here'
On Viernes mayo 18 2012 14:14:33 Johannes Bauer escribió:
> Hi group,
>
> I'm trying to dynamically add methods to a class at runtime. What I
> would like to do is have them all delegated to one common function which
> is called with the name of the function as first parameter. I.e.:
>
> class Fo
Hi group,
I'm trying to dynamically add methods to a class at runtime. What I
would like to do is have them all delegated to one common function which
is called with the name of the function as first parameter. I.e.:
class Foo():
def __init__(self):
# Some magic missing here
setattr(sel