Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30237
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: using "*" to make a list of lists with repeated (and independent) elements |
| References | <b58cj9-h5d.ln1@rama.fbx.proxad.net> |
| Date | 2012-09-26 14:43 -0700 |
| Message-ID | <7x7grgtq75.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
TP <TP@frenoespam.fr.invalid> writes:
> copies a list, he copies in fact the *pointer* to the list ....
> Is it the correct explanation?
Yes, that is correct.
> In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*"
> without this behavior?
>>> a = [[0]*3 for i in xrange(2)]
>>> a[0][0]=2
>>> a
[[2, 0, 0], [0, 0, 0]]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
using "*" to make a list of lists with repeated (and independent) elements TP <TP@frenoespam.fr.invalid> - 2012-09-26 23:20 +0200
Re: using "*" to make a list of lists with repeated (and independent) elements Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-26 15:39 -0600
Re: using "*" to make a list of lists with repeated (and independent) elements Paul Rubin <no.email@nospam.invalid> - 2012-09-26 14:43 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-26 15:07 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-26 15:28 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements Tim Chase <python.list@tim.thechases.com> - 2012-09-26 17:45 -0500
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-26 15:53 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-26 15:53 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-27 14:24 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-27 14:24 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 06:46 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-29 10:01 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-29 11:18 -0600
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-29 11:50 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-29 11:50 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements Chris Angelico <rosuav@gmail.com> - 2012-09-30 03:41 +1000
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-29 10:01 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements Ramchandra Apte <maniandram01@gmail.com> - 2012-09-29 06:46 -0700
Re: using "*" to make a list of lists with repeated (and independent) elements 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-26 14:45 -0700
csiph-web