On Wed, Nov 25, 2015 at 12:43 AM, Antoon Pardon <antoon.par...@rece.vub.ac.be> wrote: > I think that part of the problem is, that [] is not a constant object. So > that when you see a line like > > ls = [] > > It behaves more lke > > ls = [].copy() > > than what you would expect with the normal python semantics.
You're still thinking in terms of [] being a literal. It isn't; the docs describe it as "list display", and it's closer to: ls = list() except that it doesn't look up the global name. Every time you call open(), you expect it to open a fresh file handle, right? (Even if you use the same file name.) And every time you call object(), you get a new and unique sentinel object. It's the same with list(), and it's the same with square brackets as well. Start thinking of it as a constructor call rather than a literal, and you'll get past most of the confusion. ChrisA -- https://mail.python.org/mailman/listinfo/python-list