Assigning to self

Peter Otten __peter__ at web.de
Mon Jan 17 22:24:58 CET 2005


Frans Englich wrote:

> On Monday 17 January 2005 20:03, John Roth wrote:
>> "Frans Englich" <frans.englich at telia.com> wrote in message
> 
> <snip>
> 
>> In other words, you're trying to create a singleton. In general,
>> singletons are frowned on these days for a number of reasons,
>> not least because of the difficulty of testing them.
> 
> Then I have some vague, general questions which perhaps someone can reason
> from: what is then the preferred methods for solving problems which
> requires Singletons? Is it only frowned upon in Python code?

Sorry, no answer here, but do you really want a singleton?

Singleton: "Ensure a class only has one instance, and provide a global point
of access to it"

whereas

Flyweight: "Use sharing to support large numbers of fine-grained objects
efficiently"

as per "Design Patterns" by Gamma et al.

Peter




More information about the Python-list mailing list