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(SingletonWMetaCall):
pass
class MySingleton2(SingletonWMetaCall):
pass
2. access to created instances
from singleton_meta import *
class Victim1(SingletonWMetaCall):
attr = 1
class Victim2(SingletonWMetaCall):
attr = 2
assert SingletonWMetaCall._SINGLETONS == []
Victim1()
assert SingletonWMetaCall._SINGLETONS == [Victim1(), ]
Victim2()
assert SingletonWMetaCall._SINGLETONS == [Victim1(), Victim2(), ]
3. Use meta
from singleton_meta import *
class MySingleton(metaclass=SingletonMetaClass):
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(SingletonWMetaCall): # 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.4.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for singleton_meta-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c7e5aa37ecb17d1b2a9241fbe565c0e34d66a1d725477ef5d5f842f623b9e05 |
|
MD5 | a149c2d818b096ab764278a5ca0b6066 |
|
BLAKE2b-256 | bfa6f8dd2a44d2a7febd47fc2a4c7baff568a142108329ef18678d9af7927eb0 |