Singleton classes (with no such thing as static variables)

Stephen D Evans stevee at recombinant.demon.co.uk
Mon Jul 2 13:57:09 EDT 2001


You mention 'data', but do not state whether it is variable or constant data.

If you want to use a singleton to pass around constant data there is a useful
Python recipe (by Alex Martelli) on ActiveState's website, titled 'Constants in
Python'.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207

Stephen D Evans.


Giles Constant wrote:

> Hi there,
>
> Being a C++ head, it's probably more a problem with my design than a python
> problem, but I figured you guys would be able to help.
>
> I'm trying to make a class called "Environment" which will store some
> global data such that all instances of the class have access to it.  The
> alternative is to create a single instance and pass it around every single
> object in the entire project, but it gets used so frequently that it would
> be rediculous.
>
> Is there a way of doing this, or do I need a new paradigm? :-)




More information about the Python-list mailing list