Monday, October 26, 2009

Prevent to create an Instance of a Class

I think it's cool


class ClassName:
def __init__( self ):
if self.__class__ == ClassName:
raise NotImplementedError, "Cannot create object of this class"

0 comments:

Post a Comment