Question: How to only create new object instances?
s.keim at laposte.net
Thu Oct 25 09:35:23 CEST 2001
> I am trying to create new cells only when they don't exist in a given library
> of cells. In the case where they already exist in the supplied library, I
> would like the "new" cell to refer to the exisiting cell in the library.
Maybe something like this could work
self.cellName = cellName
self.library = library
if cellName in library.cellList.keys():
print "cell already exists"
return _Cell(cellName, library)
In Python 2.2 the natural way to achieve this would probably be to use
the __new__ class method and to construct the new instance 'by hand'.
More information about the Python-list