self-inheritance...
Richard Jones
richard at bizarsoftware.com.au
Thu Sep 6 19:07:29 EDT 2001
On Thursday 06 September 2001 06:14, Roman Suzi wrote:
> Interestingly enough, it works as expected:
> >>> class Dolly:
>
> ... def a(s): pass
> ...
>
> >>> class Dolly(Dolly):
>
> ... def b(s): pass
> ...
>
> >>> a = Dolly()
> >>> a.
Note that you don't actually have "self inheritance" here. Witness:
>>> class Dolly:
... def a(s): pass
...
>>> Dolly
<class __main__.Dolly at 0x8133c3c> # <<< first ID
>>> class Dolly(Dolly):
... def b(s): pass
...
>>> Dolly
<class __main__.Dolly at 0x813206c> # <<< second ID
>>> Dolly.__bases__
(<class __main__.Dolly at 0x8133c3c>,) # <<< first ID
Now sure, internally the Dolly class object think it's called Dolly - well,
it knows what name it was created under. But notice that the object ids are
different for the first and second Dolly. And the second Dolly's base classes
list references the first Dolly class instance.
> Are there any means first Dolly-class could use to
> intervene into inheritance mechanism and spoil
> it?
Sorry, I don't understand this question.
Richard
More information about the Python-list
mailing list