Semantics of the empty list

Tim Roberts timr at probo.com
Fri Jul 16 01:13:02 EDT 2004


Dave Opstad <dave.opstad at agfamonotype.com> wrote:
>
>What is curious to me is the implication that there are multiple, 
>distinct empty list objects (whose ids are not equal). Is this the case 
>for all mutable objects?

Any list, string, tuple, or dictionary can be empty.  The fact that a list
is "empty" does not automatically turn it into "THE empty list object".

Your first example creates 5 new objects, each of which becomes an empty
list, and stores a reference to each in the outer list.  Your second
example creates 1 new object, and stores 5 references to it in the outer
list.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list