Bug or wart? You make the call.

Michael Hudson mwh at python.net
Mon Mar 10 13:06:48 CET 2003

Thomas Wouters <thomas at xs4all.net> writes:

> It doesn't have an official rationale, but it's easily
> considered. Python is a very dynamic language. An instance's
> __class__ and a class's __bases__ can be dynamically changed. It is
> part of how Python Works.

Apropos of not much, I was faintly surprised this didn't raise an

/>> class C(object):
|..  def m(self, x):
|..   print x
/>> class D(object):
|..  pass
->> o = C()
->> m = o.m
->> o.__class__ = D
->> m(1)


  ROOSTA:  Ever since you arrived on this planet last night you've
           been going round telling people that you're Zaphod
           Beeblebrox, but that they're not to tell anyone else.
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 7

More information about the Python-list mailing list