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
On Tue, 23 Oct 2007 17:02:48 +, beginner wrote:
> 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 loca
beginner schrieb:
> 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 be
On Tue, 2007-10-23 at 17:02 +, beginner 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]
"c='B'" is invalid syntax. Maybe you mean "c=='B'". That doesn't make
much sense, but at least it's correct syntax.
> print c
>
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