dischdennis wrote:
> the line "raise Singleton.__single" invokes in my class the following
> error:
>
> exceptions must be classes, instances, or strings (deprecated), not
> PurchaseRequisitionController

Denis,
Jason's explanation is correct!  You are trying to use the Singleton
instance as the exception, which is not only confusing but illegal.
The argument of raise should be an instance of a class derived from
Exception.  You should define some kind of informative Exception class,
e.g.:

class SingletonException(Exception):
    pass

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

foo = Singleton()    # works
bar = Singleton()    # raises SingletonException

Dan

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to