. Python 2.1 function attributes
Pekka Pessi
Pekka.Pessi at nokia.com
Sun Feb 4 20:32:34 EST 2001
In message <Pine.GSO.4.21.0101271303540.3501-100000 at y.glue.umd.edu> Roy Katz <katz at Glue.umd.edu> writes:
>Let's add bless(). I want to change the class of an object at
>runtime. How 'bout it?
How about this:
class sm:
"State machine accepting ab*"
def __init__(self):
self.__class__ = a
valid = 0
class a(sm):
def a(self):
self.__class__ = b
class b(sm):
def b(self):
pass
valid = 1
BTW, have you never looked in the source code of pickle?
Pekka
More information about the Python-list
mailing list