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.3.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for singleton_meta-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 443918d797b141afe2b2d69b1e50c9373a3ce847d7e00bc06a6bd4ec31ab8c76 |
|
MD5 | c1ea1fa0b1075840b79e3a8437a7b2a4 |
|
BLAKE2b-256 | fd9888a5ed4f188e526e0b63ca28af6882a5650557408a18754c949e656c9dd7 |