Singleton implementation problems

Urizev urizev at gmail.com
Thu Jul 3 18:58:01 EDT 2008


Hi everyone

I have developed the singleton implementation. However I have found a
strange behaviour when using from different files. The code is
attached.

Executing main
new MySet object
No singleton instance
New singleton:
<__main__.Singleton instance at 0x2b98be474a70>
new MySet object
There is a singlenton instance
new Member
new MySet object
No singleton instance
New singleton:
<myset.Singleton instance at 0x2b98be474d88>
new Member
new MySet object
There is a singlenton instance
new Member
new MySet object
There is a singlenton instance

I do not know why, but it creates two instances of the singleton. Does
anybody know why?

Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: member.py
Type: text/x-python
Size: 175 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080704/1af78468/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myset.py
Type: text/x-python
Size: 1466 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080704/1af78468/attachment-0001.py>


More information about the Python-list mailing list