how to keep collection of existing instances and return one on instantiation

marduk usenet at marduk.letterboxes.org
Wed Oct 5 16:06:37 EDT 2005


On Wed, 2005-10-05 at 19:37 +0200, Diez B. Roggisch wrote:
> > What I wanted is multiple calls to create a new object with the same
> > parameters points to the "original" object instead of creating a new
> > one.
> 
> Read the comments. What you say is essentially the same - the data 
> matters, after all. What do you care if there are several instances
> around?
> 
> Diez 

In my case it matters more that the objects are the same.

For example I want set([Spam(1), Spam(2),
Spam(3)]).intersect(set([Spam(1), Spam(2)]) to contain two items instead
of 0.

For this and many other reasons it's important that Spam(n) is Spam(n).




More information about the Python-list mailing list