hi
this is what I wrote
class MySingleton(object):
    _instance = None
    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(MySingleton, cls).__new__(cls)
        return cls._instance

I did  unit test on this ..
def setUp(self):
    self.tm=TM()

def test_single_instance(self):
    #create two instances of TM, check if they are the same
    tm1=TM()
    self.assertTrue(self.tm is tm1)
Also,printing the object instance shows same value (ie <mytm.TM object
at 0x94a83ec> )

thanks for the reply
jim


On Oct 7, 8:23 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Oct 7, 3:20 pm, jimgardener <jimgarde...@gmail.com> wrote:

> What is the MySingleton superclass? There's nothing in the code you've
> posted that shows that TM is actually a singleton.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to