Maric Michaud wrote: > Le lundi 04 septembre 2006 22:29, Carl Banks a écrit : > >>BTW, __class__ is available to instances. (Were you thinking of >>__bases__?) > > > hmmm, I guess they're not the same, are they ? > > but you're right, __bases__ and some others are class attributes not > available > in instances, I wonder where is this documented and I'm not enough familiar > with python' source code to find this. > > Also this create weird things, like a code posted on this list, which was > very confusing and looked to something like : > > In [24]: class A(object) : > ....: __class__ = list > ....: > ....: > > In [25]: A.__class__ > Out[25]: <type 'type'> > > In [26]: A().__class__ > Out[26]: <type 'list'> > > In [27]: isinstance(A(), list) # ouch ! > Out[27]: True > > In [29]: type(A()) > Out[29]: <class '__main__.A'> > > In [30]: type(A()).mro() > Out[30]: [<class '__main__.A'>, <type 'object'>] > > You are beginning to appreciate the meaning of the phrase "Python is a language for use by consenting adults". The general philosophy is to provide a coherent and easily-used framework in the expectation that users will not shoot themselves in the foot (too often).
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list