Final classes like in java???
Fred L. Drake, Jr.
fdrake at acm.org
Tue Nov 16 14:40:22 EST 1999
Arinte writes:
> Is there a way you can define your python class to be final or not able to
> be inherited from?
Not guaranteed, but this should be good enough:
------------------------------------------------------------------------
class FinalClass:
def __init__(self):
if self.__class__ is not FinalClass:
raise SomeError, "you can't subclass from me!"
------------------------------------------------------------------------
Whether or not this is a good idea is another thing.
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
Corporation for National Research Initiatives
More information about the Python-list
mailing list