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.

If you know that you'll use all list entries, you
might as well do it right from the start. Instead
of:

l = [C()] * n

you can do:

l = [C() for i in range(n)]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to