Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Singleton/Python/singleton-1.py
Normal file
19
Task/Singleton/Python/singleton-1.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
>>> class Borg(object):
|
||||
__state = {}
|
||||
def __init__(self):
|
||||
self.__dict__ = self.__state
|
||||
# Any other class names/methods
|
||||
|
||||
|
||||
>>> b1 = Borg()
|
||||
>>> b2 = Borg()
|
||||
>>> b1 is b2
|
||||
False
|
||||
>>> b1.datum = range(5)
|
||||
>>> b1.datum
|
||||
[0, 1, 2, 3, 4]
|
||||
>>> b2.datum
|
||||
[0, 1, 2, 3, 4]
|
||||
>>> b1.datum is b2.datum
|
||||
True
|
||||
>>> # For any datum!
|
||||
Loading…
Add table
Add a link
Reference in a new issue