Bug or wart? You make the call.
Michael Hudson
mwh at python.net
Mon Mar 10 07:06:48 EST 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
exception:
/>> class C(object):
|.. def m(self, x):
|.. print x
\__
/>> class D(object):
|.. pass
\__
->> o = C()
->> m = o.m
->> o.__class__ = D
->> m(1)
1
Cheers,
M.
--
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