Python : Singleton class object to persist list between imports ? (Like django admin register)
Question: I want to have `dict / list` to which I can add values, just like models can
be added to the admin register in django !

My attempt : (`package -> __init__.py`)

    
    
    # Singleton object
    
    # __init__.py (Package: pack)
    class remember:
      a = []
      def add(data):
        a.append[data]
    
      def get():
        return a
    
    obj = remember()
    
    
    # models1.py
    import pack
    
    pack.obj.add("data")
    
    # models2.py
    import pack
    
    pack.obj.add("data2")
    print pack.obj.get()   
    

# We should get: ["data", "data2"] # We get : ["data2"]

How to achieve the desired functionality ?

Some say that methods can do this if you don't need sub-classing, how to do
this with methods ?

**Update:** To be more clear :

> Just like `django admin register` any one can import and register itself
> with admin, so that register is persisted between imports.


Answer: If it's a singleton you're after, have a look at
[this](http://www.garyrobinson.net/2004/03/python_singleto.html) old blog
post. It contains a link to a well documented implementation
([here](http://www.garyrobinson.net/singletonmixin.py)).

