Writing an immutable object in python

Magnus Lycka lycka at carmen.se
Thu Oct 20 13:11:46 CEST 2005


Mapisto wrote:
> Ok, I've understood my mistake.
> 
> Now, my list contains a shared entry of an empty object. When an entry
> is needed to be changed, I check if the entry is the shared empty
> object; in that case I create a new unique instance. If the entry is
> already a unique instance, I use it, so the empty object isn't touched.

It's probably less confusing if you make a list
of None, instead of a list of references to an
instance object you don't use anyway.



More information about the Python-list mailing list