April 20th, 2004, 05:41 PM
Hi. I am trying to create a class that will allow only one instance of itself to be created. I was looking for something like static(in c++) for python. Is there something like this? Thanks!
April 20th, 2004, 06:30 PM
What you want to do is to implement the Singleton pattern. You'll want to look at the Overriding the __new__ method section of Unifying types and classes. I've linked directly to the specific section where implementation is discussed but I recommend reading the entire essay.
Originally Posted by jimo9
Last edited by percivall; April 20th, 2004 at 06:35 PM.
April 21st, 2004, 02:52 AM