Uhm? If I pass different parameters I want to have
different instances. The Singleton behaviour is recovered
only when I pass always the same arguments, in
particular when I pass 0-arguments:

>>> class Foobar:
...     __metaclass__ = Memoize
...
>>> Foobar()
<__main__.Foobar object at 0xb7defbcc>
>>> Foobar()
<__main__.Foobar object at 0xb7defbcc>
>>> Foobar()
<__main__.Foobar object at 0xb7defbcc>

Of course if for Singleton you mean "whatever I pass
to the constructor it must always return the same
instance" then this pattern is not a Singleton.
This is why I call it memoize ;)

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

Reply via email to