MethodType in python 2.2

G

George Sakkis

Hi all,

I wonder why types.MethodType fails under python 2.2:

Python 2.2.2 (#1, Jun 25 2003, 18:52:43)
[GCC 3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information..... def f(self,attr): return getattr(self,attr)
.... g = types.MethodType(f,None)
....
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in X
TypeError: cannot create 'instance method' instances


The same code under 2.4 (and I believe 2.3) runs fine.

Python 2.4b1 (#1, Oct 25 2004, 17:07:48)
[GCC 3.3 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information..... def f(self,attr): return getattr(self,attr)
.... g = types.MethodType(f,None)
....<bound method X.f of <__main__.X instance at 0x2a97f23e60>>


Is it possible to get around this in 2.2 ? Thanks in advance,

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top