Re: Binding first parameter of method to constant value

2012-05-18 Thread Johannes Bauer
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( >

Re: Binding first parameter of method to constant value

2012-05-18 Thread Steven D'Aprano
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'

Re: Binding first parameter of method to constant value

2012-05-18 Thread DPalao
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

Binding first parameter of method to constant value

2012-05-18 Thread Johannes Bauer
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