importing a method

Flavio fccoelho at gmail.com
Mon Nov 28 15:58:12 EST 2005


> If you have a function f and want to make an instancemethod out of it,
> you can simply call f.__get__(theinstance, theclass) and that will build
> and return the new instancemethod you require.

I think that

f.show = MethodType(show,f)

is less cryptic than  f.__get__(instance, class)

Flávio




More information about the Python-list mailing list