Package pulp :: Package server :: Module util :: Class Singleton
[hide private]
[frames] | no frames]

Type Singleton

source code

object --+    
         |    
      type --+
             |
            Singleton


Singleton metaclass. To make a class instance a singleton, use this class
as your class's metaclass as follows:

class MyClass(object):
    __metaclass__ = Singleton

Singletons are created by passing the exact same arguments to the
constructor. For example:

class T():
    __metaclass__ = Singleton
    
    def __init__(self, value=None):
        self.value = value
    
t1 = T()
t2 = T()
t1 is t2
True
t3 = T(5)
t4 = T(5)
t3 is t4
True
t1 is t3
False

Instance Methods [hide private]
 
__init__(self, name, bases, ns)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__call__(self, *args, **kwargs)
x(...)
source code

Inherited from type: __cmp__, __delattr__, __getattribute__, __hash__, __new__, __repr__, __setattr__, __subclasses__, mro

Inherited from object: __reduce__, __reduce_ex__, __str__

Properties [hide private]

Inherited from type: __base__, __bases__, __basicsize__, __dictoffset__, __flags__, __itemsize__, __mro__, __name__, __weakrefoffset__

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, bases, ns)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__call__(self, *args, **kwargs)
(Call operator)

source code 

x(...)

Overrides: type.__call__
(inherited documentation)