create perfect singletons meta
Reason this release was yanked:
while not used anywhere use new vertion!
Project description
singleton_meta
Features
- perfect singleton (maybe thread safe!)
- collect all instances
License
See the LICENSE file for license rights and limitations (MIT).
Release history
See the HISTORY.md file for release history.
Installation
pip install singleton-meta
Import
from singleton_meta import *
GUIDE
See tests and source for other examples.
1. Use simple nesting (common)
from singleton_meta import *
class MySingleton(Singleton):
pass
class MySingleton2(Singleton):
pass
2. access to created instances
from singleton_meta import *
class Victim1(Singleton):
attr = 1
class Victim2(Singleton):
attr = 2
assert Singleton._SINGLETONS == []
Victim1()
assert Singleton._SINGLETONS == [Victim1(), ]
Victim2()
assert Singleton._SINGLETONS == [Victim1(), Victim2(), ]
3. Use meta
from singleton_meta import *
class MySingleton(metaclass=SingletonMeta):
pass
4. NOTICE: all your Singletons must be only last classes!
don't use nesting from any Your Singletons!
from singleton_meta import *
class MySingleton(Singleton): # OK
pass
class MySingleton2(MySingleton): # WRONG
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
singleton_meta-0.0.2.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for singleton_meta-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9603ea2439c0232da9da6e0178d720b2b1a8de5f4f833f4cb967934f9b8f90b5 |
|
MD5 | 478fe363a1fd9e034e8da88585668120 |
|
BLAKE2b-256 | d8d8e322cb1f81d1bed141286c3014278213f17694106b32c83120582a73197e |