Paolino wrote: > Jiri Barton wrote: > >>Hi everyone, >> >>I have a problem with initialization. >> >> >>>>>a, b = [[]]*2 >>>>>a.append(1) >>>>>b >> >>[1] >> >>Why is this? Why does not this behave like the below: >> > > >>> a, b = [[]]*2 > >>> a==b > True Ooops I should write 'a is b' > > >>And, just to add to my confusion: >> >> >> >>>>>[[]]*2 >> >>[[], []] >> >> >>>>>[[], []] == [[]]*2 >> >>True > > This confuses me also,looks like empty lists share same object. This is actually OK as lists are compared for their contents ;-)
> Paolino > > > > > > > ___________________________________ > Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB > http://mail.yahoo.it ___________________________________ Aggiungi la toolbar di Yahoo! Search sul tuo Browser, e'gratis! http://it.toolbar.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list