Re: MethodType in python 2.2
From: Terry Reedy (tjreedy_at_udel.edu)
Date: 11/10/04
- Next message: Terry Reedy: "Re: Problems with user input"
- Previous message: Terry Reedy: "Re: Concise idiom to initialize dictionaries"
- Maybe in reply to: George Sakkis: "MethodType in python 2.2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: python-list@python.org Date: Tue, 9 Nov 2004 21:10:04 -0500
"George Sakkis" <gsakkis@eden.rutgers.edu> wrote in message
news:Pine.GSO.4.58.0411092019550.25667@er3.rutgers.edu...
> 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.
>>>> import types
>>>> class X:
> ... 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
In 2.2, *some* type objects, like int, were turned into callable
contructors as part of the introduction of new-type classes.
> The same code under 2.4 (and I believe 2.3) runs fine.
When the experiment proved to be a success, additional type objects were
converted.
> Is it possible to get around this in 2.2 ? Thanks in advance,
Perhaps the new module. Don't know for sure.
Terry J. Reedy
]
- Next message: Terry Reedy: "Re: Problems with user input"
- Previous message: Terry Reedy: "Re: Concise idiom to initialize dictionaries"
- Maybe in reply to: George Sakkis: "MethodType in python 2.2"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|