Singleton Class Exception

dischdennis d.schulz81 at
Mon Nov 13 18:04:46 CET 2006

Hello List,

I would like to make a singleton class in python 2.4.3, I found this
pattern in the web:

class Singleton:
    __single = None
    def __init__( self ):
        if Singleton.__single:
            raise Singleton.__single
        Singleton.__single = self

the line "raise Singleton.__single" invokes in my class the following

exceptions must be classes, instances, or strings (deprecated), not

Greetings, Dennis

More information about the Python-list mailing list