Duncan Booth wrote:
> Steve Holden <[EMAIL PROTECTED]> wrote:
>
>>> For a moment I thought that maybe list comprehension has its own
>>> scope, but it doesn't seem to be so:
>>> print [[y for y in range(8)] for y in range(8)]
>>> print y
>>>
>>> Does anybody understand it?
>>>
>>>
>> This isn't _a
Duncan Booth wrote:
> For the OP, in some languages (e.g. C) 'for' loops typically calculate
> the value of the loop control variable based on some expression
> involving the previous value. Python isn't like that. In Python the data
> used to compute the next value is stored internally: you canno
Steve Holden <[EMAIL PROTECTED]> wrote:
>> For a moment I thought that maybe list comprehension has its own
>> scope, but it doesn't seem to be so:
>> print [[y for y in range(8)] for y in range(8)]
>> print y
>>
>> Does anybody understand it?
>>
>>
> This isn't _a_ list comprehension, it's *tw
Piotr Sobolewski wrote:
> Hello,
>
> there is something I don't understand about list comprehensions.
>
> I understand how does this work:
> print [[y for x in range(8)] for y in range(8)]
>
> However I don't understand why this one works:
> print [[y for y in range(8)] for y in range(8)]
>
> I
Hello,
there is something I don't understand about list comprehensions.
I understand how does this work:
print [[y for x in range(8)] for y in range(8)]
However I don't understand why this one works:
print [[y for y in range(8)] for y in range(8)]
In this second example I have one loop nested i