En Fri, 09 Mar 2007 23:58:59 -0300, Steven D'Aprano
<[EMAIL PROTECTED]> escribió:
> You know, now that Python has a warnings module, it would be really good
> if list-of-lists*int raised a warning. Does anyone know if that's
> feasible
> or possible? It needn't catch every imaginable Gotcha, j
On Fri, 09 Mar 2007 17:30:09 -0800, kghose wrote:
> Hi,
>
> The following code
>
> listoflists = [[]]*2
> listoflists[0].append(1)
>
> appends(1) to both listoflists[0] and listoflists[1] (which I did not
> expect)
I think you will find the same question raised barely a few hours ago.
Hint:
>
En Fri, 09 Mar 2007 22:30:09 -0300, kghose <[EMAIL PROTECTED]>
escribió:
> The following code
>
> listoflists = [[]]*2
> listoflists[0].append(1)
>
> appends(1) to both listoflists[0] and listoflists[1] (which I did not
> expect)
See latest posts on this list, or read the FAQ.
--
Gabriel Gene
On Mar 9, 8:30 pm, "kghose" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> The following code
>
> listoflists = [[]]*2
> listoflists[0].append(1)
>
> appends(1) to both listoflists[0] and listoflists[1] (which I did not
> expect)
>
> while
>
> listoflists = [[]]*2
> listoflists[0] = [1]
> listoflists[0].appe
Hi,
The following code
listoflists = [[]]*2
listoflists[0].append(1)
appends(1) to both listoflists[0] and listoflists[1] (which I did not
expect)
while
listoflists = [[]]*2
listoflists[0] = [1]
listoflists[0].append(2)
works as expected.i.e. only listoflists[0] gets 2 appended to it and
any