What are super()'s semantics?
steve at holdenweb.com
Tue Sep 5 08:32:53 CEST 2006
Maric Michaud wrote:
> Le lundi 04 septembre 2006 22:29, Carl Banks a écrit :
>>BTW, __class__ is available to instances. (Were you thinking of
> 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 : class A(object) :
> ....: __class__ = list
> In : A.__class__
> Out: <type 'type'>
> In : A().__class__
> Out: <type 'list'>
> In : isinstance(A(), list) # ouch !
> Out: True
> In : type(A())
> Out: <class '__main__.A'>
> In : type(A()).mro()
> Out: [<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).
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
More information about the Python-list