Creating a List of Empty Lists

r.e.s. r.s at XXmindspring.com
Fri Dec 5 17:37:33 EST 2003


"David M. Cooke" wrote ...
> "r.e.s." wrote:
> 
> > But something's wrong with that explanation, because 
> > of the following:
> >
> >     >>> a = 'gobble'
> >     >>> a is 'gobble'
> >     True
> >
> > Surely `'gobble'` is not the name of an already-existing 
> > object, so I expected exactly the same result as for 
> > `100` and `[]`.  What's going on there?  
> 
> Actually, your second use of 'gobble' *is* an already-existing object.
> Python 'interns' string constants, i.e., reuses them. 
<snip>

Thanks. That explains it.

--
r.e.s.





More information about the Python-list mailing list