Re: [Tutor] Object defined by initialization parameters ADDITION

2006-04-24 Thread Bob Gailer
Bob Gailer wrote: Andre Engels wrote: Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? Use a "factory" function, and store a dictionary of instances as a

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Bob Gailer
Andre Engels wrote: > Is it possible to define a class in such a way, that if twice an > object is made with the same initialization parameters, the same > object is returned in both cases? > Use a "factory" function, and store a dictionary of instances as a class property: class myObj(object)

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Andre Engels wrote: > Is it possible to define a class in such a way, that if twice an object > is made with the same initialization parameters, the same object is > returned in both cases? Yes. The idea is to have the "constructor" really be a function that delegates o

[Tutor] Object defined by initialization parameters

2006-04-24 Thread Andre Engels
Is it possible to define a class in such a way, that if twice an object is made with the same initialization parameters, the same object is returned in both cases? More specifically, suppose I have the following program: class myObj(object): def __init__(self,a): self._a = a s