On Jul 17, 8:20 am, Craig Allen <[EMAIL PROTECTED]> wrote:

> Is it pythonic?

You probably can't get anymore pythonic than something written by the
BDFL.  In describing the use of __new__ in <i>Unifying types and
classes in Python 2.2</i> he gives this recipe for a Singleton.


class Singleton(object):
    def __new__(cls, *args, **kwds):
        it = cls.__dict__.get("__it__")
        if it is not None:
            return it
        cls.__it__ = it = object.__new__(cls)
        it.init(*args, **kwds)
        return it
    def init(self, *args, **kwds):
        pass

You might find this a useful starting point.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to