Terry Reedy wrote:
> "Steve Holden" <[EMAIL PROTECTED]> wrote in message
[...]
> | Well, the fact that the bound variable in the list comprehension does
> | indeed remain outside the construct is simply the result of an
> | over-zealous wish to emulate for loop semantics. The original reasoning,
>
"Steve Holden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Micah Cowan wrote:
| > "Jerry Hill" <[EMAIL PROTECTED]> writes:
| >
| >> On Fri, Feb 29, 2008 at 10:01 PM, Ken Pu <[EMAIL PROTECTED]>
wrote:
| >>> Is there a way for me keep the iterating variable in list
| >>> compre
Micah Cowan wrote:
> "Jerry Hill" <[EMAIL PROTECTED]> writes:
>
>> On Fri, Feb 29, 2008 at 10:01 PM, Ken Pu <[EMAIL PROTECTED]> wrote:
>>> Is there a way for me keep the iterating variable in list
>>> comprehension local to the list comprehension?
>> Kind of. You can use a generator expression
Ken Pu wrote:
> So the list comprehension actually creates a variable x which is
> somewhat unexpected.
> Is there a way for me keep the iterating variable in list
> comprehension local to the list comprehension?
Not with a list comprehension, but generator expressions do not leak their
iterating
"Jerry Hill" <[EMAIL PROTECTED]> writes:
> On Fri, Feb 29, 2008 at 10:01 PM, Ken Pu <[EMAIL PROTECTED]> wrote:
>> Is there a way for me keep the iterating variable in list
>> comprehension local to the list comprehension?
>
> Kind of. You can use a generator expression instead of a list
> compr
On Fri, Feb 29, 2008 at 10:01 PM, Ken Pu <[EMAIL PROTECTED]> wrote:
> Is there a way for me keep the iterating variable in list
> comprehension local to the list comprehension?
Kind of. You can use a generator expression instead of a list
comprehension, and those don't leak their internal varia
"Ken Pu" <[EMAIL PROTECTED]> writes:
> Hi all,
>
> I observed an interesting yet unpleasant variable scope behaviour with
> list comprehension in the following code:
>
> print [x for x in range(10)]
> print x
>
> It outputs:
>
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> 9
>
> So the list comprehension actu
Hi all,
I observed an interesting yet unpleasant variable scope behaviour with
list comprehension in the following code:
print [x for x in range(10)]
print x
It outputs:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
9
So the list comprehension actually creates a variable x which is
somewhat unexpected.
Is th