Hi,

I was looking at ways to implement a Singleton class. I saw some methods described on the PythonSingleton wiki (http://c2.com/cgi/wiki?PythonSingleton). I implemented the following.

<code>

module: A.py
----------------------
class Singleton:
   def __init__(self):
      #do something


singleton_instance = Singleton()



Then in any other module (eg B.py):

from A import singleton_instance


</code>

singleton_instance will be created only once and can be reused in other modules. But is this ok? I am trying to figure out what are the disadvantages of using the above method. I would appreciate any comments. thanks.

regards,
Satchit

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to