Damien Wyart wrote:
Thanks for these important and useful additions, they are very welcome !
In writing my answer I had immutables in mind, but mutables are a bit
more dangerous, here...
Not *that* much though.
The first construct can't be used, but he can use
[copy.copy(Foo) for _ in
Hello,
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so? E.g.,
something like [Foo * 20] (which is obviously not the right way) that
would create [Foo, Foo, Foo, ...,Foo].
I tried looking through the
* Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
Maybe :
[ Foo ] * 20
or, more verbose,
[ Foo for _ in range(20) ]
?
--
DW
--
Rocco Moretti wrote:
Damien Wyart wrote:
* Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
Maybe :
[ Foo ] * 20
or, more verbose,
[ Foo for _
Damien Wyart wrote:
* Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
Maybe :
[ Foo ] * 20
or, more verbose,
[ Foo for _ in range(20) ]
If
Thanks for these important and useful additions, they are very welcome !
In writing my answer I had immutables in mind, but mutables are a bit
more dangerous, here...
--
DW
--
http://mail.python.org/mailman/listinfo/python-list
Damien Wyart wrote:
* Efrat Regev [EMAIL PROTECTED] in comp.lang.python:
Suppose I have some non-numerical Foo and would like to create a list
of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
Maybe :
[ Foo ] * 20
or, more verbose,
[ Foo for _ in range(20) ]
?
On Tue, 03 Jan 2006 19:21:32 +0100, Damien Wyart wrote:
Thanks for these important and useful additions, they are very welcome !
In writing my answer I had immutables in mind, but mutables are a bit
more dangerous, here...
Mutables are easy to deal with using the copy module and list