On 3/10/06, Michal Kwiatkowski <[EMAIL PROTECTED]> wrote: > Alex Martelli napisaĆ(a): > >> So another question arise. Is it possible to make function a method (so > >> it will receive calling object as first argument)? > > > > Sure, impor types then call types.MethodType: > > > > f = types.MethodType(f, obj, someclass) > > > > (f.__get__ is also fine for Python-coded functions) -- make sure that > > someclass is obj's class or some ancestor of it, of course. > > I wasn't aware of types module. Thanks for your reply.
The new module will also allow you create entirely new classes (among other things) at run time, which might be a cleaner way than monkey-patching in new superclasses. > > mk > -- > . o . >> http://joker.linuxstuff.pl << > . . o It's easier to get forgiveness for being wrong > o o o than forgiveness for being right. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list