On Oct 23, 12:02 pm, beginner <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> If I have a list comprehension:
>
> ab=["A","B"]
> c = "ABC"
> [1.0 if c=='A' else c='B' for c in ab]
> print c
>
> >>"B"
>
> My test shows that if c is not defined before the list comprehension,
> it will be created in the list comprehension; if it is defined before
> the list comprehension, the value will be overwritten. In other words,
> temp variables are not local to list comprehensions.
>
> My question is why is this and is there any way to make c local to
> list comp?
>
> Thanks,
> Geoffrey

I see.

Thanks for everyone's help!

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to