Adding method to object
Dave Benjamin
ramen at lackingtalent.com
Wed Dec 3 15:26:00 EST 2003
More information about the Python-list mailing list
Wed Dec 3 15:26:00 EST 2003
- Previous message (by thread): Adding method to object
- Next message (by thread): Advice on Python C modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <72krsvcpeur8hhu74s4bhlsq3bf60fu055 at 4ax.com>, Gonçalo Rodrigues wrote: > If you want to leave out the f as arg (call it like an instance > method) then > >>>> import new >>>> help(new.instancemethod) > Help on class instancemethod in module __builtin__: > > class instancemethod(object) > | instancemethod(function, instance, class) > | > | Create an instance method object. > | > ... > > And > > new.instancemethod(incr, f, f.__class__) > > Should do the trick. I tried to bring this up several weeks ago but nobody replied, so I'm bringing it up again. I still see people recommending "new.instancemethod", yet "help(new)" says that the "new" module is deprecated. The seemingly identical "types.MethodType" ought to be its replacement, even though I think "new.instancemethod" is more clear. If you stringify types.MethodType, it says "<type 'instancemethod'>". The help for instancemethod, above, says that instancemethod is in the __builtin__ module, but it is neither a builtin nor available in the __builtin__ module. This is confusing. Can we decide on a community standard for the appropriate way to create new instance methods, and resolve the documentation discrepancies? Thankya kindly, Dave -- .:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:. : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
- Previous message (by thread): Adding method to object
- Next message (by thread): Advice on Python C modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list