self-inheritance...
Emile van Sebille
emile at fenx.com
Thu Sep 6 07:13:23 EDT 2001
One way would be to add a class attribute stashing the the id of Dolly, and
later checking that it hasn't changed.
class Dolly:
def a(s):
if s.__clsid__ == id(Dolly):
return "\n\nSource Dolly Class"
else:
return "\n\nSelf-inheritance not allowed"
Dolly.__clsid__ = id(Dolly)
d = Dolly()
print d.a()
class Dolly(Dolly):
def b(s): pass
a = Dolly()
print a.a()
--
Emile van Sebille
emile at fenx.com
---------
"Roman Suzi" <rnd at onego.ru> wrote in message
news:mailman.999720984.24088.python-list at python.org...
> Interestingly enough, it works as expected:
>
> >>> class Dolly:
> ... def a(s): pass
> ...
> >>> class Dolly(Dolly):
> ... def b(s): pass
> ...
> >>> a = Dolly()
> >>> a.
> a.__class__( a.__doc__ a.__module__ a.a( a.b(
>
> Are there any means first Dolly-class could use to
> intervene into inheritance mechanism and spoil
> it?
>
> Sincerely yours, Roman Suzi
> --
> _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
> _/ Wednesday, September 05, 2001 _/ Powered by Linux RedHat 6.2 _/
> _/ "... Clinton sandwich: $5 of baloney and $20 in taxes" _/
>
>
More information about the Python-list
mailing list