On Tuesday, March 22, 2016 at 12:01:10 AM UTC+5:30, Maurice wrote:
> Just figured why:
>
> If I type this on the kernel:
>
> weirdList = [[0]*3]*5
>
> weirdList
> Out[257]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
>
> weirdList[0][0] = 1
>
> weirdList
> Out[259]: [[1, 0, 0], [1,
On Tue, 22 Mar 2016 12:35 pm, Paul Rubin wrote:
> Maurice writes:
>> I have a list such [6,19,19,21,21,21]
>> Therefore the resulting list should be:
>> [0,0,0,0,0,0,1,0,0,0...,2,0,3,0...0]
>
> Rather than a sparse list you'd typically want a dictionary (untested):
>
> from collections import
On Tuesday 22 March 2016 11:31, Ben Bacarisse wrote:
> Ian Kelly writes:
>
>> On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse
>> wrote:
>>> For experts here: why can't I write a lambda that has a statement in it
>>> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
>>
>> https://docs.py
Maurice writes:
> I have a list such [6,19,19,21,21,21]
> Therefore the resulting list should be:
> [0,0,0,0,0,0,1,0,0,0...,2,0,3,0...0]
Rather than a sparse list you'd typically want a dictionary (untested):
from collections import defaultdict
the_list = [0,0,0,0,0,0,1,0,0,0...,2,0,3,0...0]
On Tue, Mar 22, 2016 at 11:31 AM, Ben Bacarisse wrote:
> However, the explanation ("because Python’s syntactic framework can't
> handle statements nested inside expressions") seemed, at first, to be
> saying you can't because you can't! But the term "syntactic framework"
> hints that it's not rea
Ian Kelly writes:
> On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse wrote:
>> For experts here: why can't I write a lambda that has a statement in it
>> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
>
> https://docs.python.org/3/faq/design.html#why-can-t-lambda-expressions-contain-st
On Tue, 22 Mar 2016 05:26 am, Maurice wrote:
> I have a list such [6,19,19,21,21,21] (FYI this is the item of a certain
> key in the dictionary)
>
> And I need to convert it to a list of 32 elements (meaning days of the
> month however first element ie index 0 or day zero has no meaning -
> keepi
On Mon, Mar 21, 2016 at 2:12 PM, Ian Kelly wrote:
> On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse wrote:
>> For experts here: why can't I write a lambda that has a statement in it
>> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
>
> https://docs.python.org/3/faq/design.html#why-can-
On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse wrote:
> For experts here: why can't I write a lambda that has a statement in it
> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
https://docs.python.org/3/faq/design.html#why-can-t-lambda-expressions-contain-statements
--
https://mail.p
Maurice writes:
> Hello, hope everything is okay. I think someone might have dealt with
> a similar issue I'm having.
>
> Basically I wanna do the following:
>
> I have a list such [6,19,19,21,21,21] (FYI this is the item of a
>certain key in the dictionary)
>
> And I need to convert it to a list
On 21/03/2016 18:30, Maurice wrote:
Just figured why:
If I type this on the kernel:
weirdList = [[0]*3]*5
weirdList
Out[257]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
weirdList[0][0] = 1
weirdList
Out[259]: [[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]]
All first ele
Maurice wrote:
> Hello, hope everything is okay. I think someone might have dealt with a
> similar issue I'm having.
>
> Basically I wanna do the following:
>
> I have a list such [6,19,19,21,21,21] (FYI this is the item of a certain
> key in the dictionary)
>
> And I need to convert it to a li
On 21/03/2016 18:26, Maurice wrote:
Hello, hope everything is okay. I think someone might have dealt with a similar
issue I'm having.
Basically I wanna do the following:
I have a list such [6,19,19,21,21,21] (FYI this is the item of a certain key in
the dictionary)
And I need to convert it t
Just figured why:
If I type this on the kernel:
weirdList = [[0]*3]*5
weirdList
Out[257]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
weirdList[0][0] = 1
weirdList
Out[259]: [[1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0], [1, 0, 0]]
All first elements of the sublists also changes. I
Hello, hope everything is okay. I think someone might have dealt with a similar
issue I'm having.
Basically I wanna do the following:
I have a list such [6,19,19,21,21,21] (FYI this is the item of a certain key in
the dictionary)
And I need to convert it to a list of 32 elements (meaning days
15 matches
Mail list logo