Singleton classes (with no such thing as static variables)

Giles Constant gilesc at hyperlink-interactive.co.uk
Tue Jul 3 06:06:53 EDT 2001


just what I was looking for :-)

thanks loads.

(with respect to constant/variable data, I'm actually passing around a
class which can provide database cursors from a single active connection,
but I can do something with what you've pointed me at!)

-- 
Giles Constant, Systems Programmer
Hyperlink Interactive
http://www.hyperlink-interactive.co.uk

On Mon, 2 Jul 2001, Stephen D Evans wrote:

> 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