importing a method

Flavio fccoelho at
Mon Nov 28 21:54:48 CET 2005

> First of all,why do you think the new module is deprecated?  (I can't
> find anything in the docs to indicate this.)

Its in the docs of python 2.4. I dont know about older versions:

Help on module new:

    new - Create new objects of various types.  Deprecated.



    This module is no longer required except for backward
    Objects of most types can now be created by calling the type

> As for using MethodType in the types module:  There's nothing in the
> module documentation that suggests that you can call MethodType as a
> function as you suggest, only that it is the name of the type of
> methods of user-defined class instances..  So, while calling it might
> work, it sounds like you are using an undocumented feature...

If you look at, all it does is import the functions from types
and rename them. For MethodType is goes like this

from types import MethodType as instancemethod

so instance method *is* Methodtype.

Moreover, I tried and it works ;-)

So this solution is perfect once adapted not to depend on "new".



More information about the Python-list mailing list