mark at microenh.com
Thu Sep 30 15:27:53 CEST 2010
Would the following code be appropriate to implement a singleton instance?
""" class that will have only one instance in the application """
singleton = Singleton()
The single instance of the class would be instantiated the first time the module is imported. It would be impossible for any other code to instantiate another instance.
I had originally thought of a slightly shorter, but less Pythonic version
""" note the non-standard lowercase class name """
singleton = singleton()
Comments are welcome.
More information about the CentralOH