singleton in python ?

Andrew Dalke dalke at dalkescientific.com
Mon May 6 04:05:48 EDT 2002


fritz steindl:
>what is the best way to implement a singleton in python ???

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
Title: Singleton? We don't need no stinkin' singleton: the Borg
design pattern

>i miss static variables and functions in python (or i don't see them :-)

Use module variables and module functions.

There are other things you could do as well.

What you're experiencing is pretty common for people switching from
one language to another.  In language J you know how to solve a
problem using a certain viewpoint.  When learning language P you
still want to solve the same problem, but haven't learned yet how
what the right viewpoint is for P.

You might instead describe what you're trying to do and we could
suggest a more Pythonic way to solve it.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list