python 2.1 singleton

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexiev Nikolay

    python 2.1 singleton

    I need a simple implementation of singleton that will work on python 2.1. I
    havn't got idea how to creat without staticmethod. Can you give me a
    solution ??? 10x in advance

    ---------------------------------------
    Best regards,
    Alexiev, Nikolay
    e-mail: alexiev@actives olutions.bg
    phone: +359 2 8753543


  • Duncan Booth

    #2
    Re: python 2.1 singleton

    "Alexiev Nikolay" <alexiev@active solutions.bg> wrote in
    news:mailman.11 2.1066205794.21 92.python-list@python.org :
    [color=blue]
    > I need a simple implementation of singleton that will work on python
    > 2.1. I havn't got idea how to creat without staticmethod. Can you give
    > me a solution ??? 10x in advance
    >[/color]

    The simplest singleton implementation, which works for any version of
    Python is simply to use a module as your singleton instead of a class. You
    can get hold of the singleton object from anywhere simply by importing it.
    All functions defined in a module are effectively static methods on the
    module object.


    --
    Duncan Booth duncan@rcp.co.u k
    int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
    "\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?

    Comment

    Working...