Edward Elliott wrote:
> Edward Elliott wrote:
>> assignemnt is actually an expression in those languages, not a
>> statement.
>
> s/statement/operator/
it was probably clearer the first time, but let me rephrase:
in C/Java, assignment is neither a statement not an operator. it is an
expressio
Edward Elliott wrote:
> assignemnt is actually an expression in those languages, not a
> statement.
s/statement/operator/
--
http://mail.python.org/mailman/listinfo/python-list
Edward Elliott a écrit :
> Roy Smith wrote:
>
(snip)
>>The lack of embedded assignments leads to slightly more verbose code in
>>situations like this, but on the other hand, it avoids the typical C
>>disaster of writing a whole function as a one liner.
>
> Writing disasters in python just takes
Roy Smith wrote:
> decision. In Python, assignment is not an operator with side effects like
> in C or Java, but a statement.
assignemnt is actually an expression in those languages, not a
statement.
> The lack of embedded assignments leads to slightly more verbose code in
> situations like
Gary Wessle wrote:
> is there a way to make an assignment in the condition of "if"
No.
> nx = re.compile('regex')
> if x = nx.search(text):
>funCall(text, x))
Use:
nx = re.compile('regex')
x = nx.search(text)
if x:
funCall(text, x)
--
Ben Caradoc-Davies <[EMAIL PROTECTED]>
http://win
Gary Wessle a écrit :
> Hi
>
> is there a way to make an assignment in the condition of "if" and use
> it later
No.
>, e.g.
>
> nx = re.compile('regex')
> if nx.search(text):
>funCall(text, nx.search(text))
>
> nx.search(text) is evaluated twice, I was hoping for something like
>
> nx = r
In article <[EMAIL PROTECTED]>,
Gary Wessle <[EMAIL PROTECTED]> wrote:
> Hi
>
> is there a way to make an assignment in the condition of "if" and use
> it later, e.g.
>
> nx = re.compile('regex')
> if nx.search(text):
>funCall(text, nx.search(text))
>
> nx.search(text) is evaluated twice,
Hi
is there a way to make an assignment in the condition of "if" and use
it later, e.g.
nx = re.compile('regex')
if nx.search(text):
funCall(text, nx.search(text))
nx.search(text) is evaluated twice, I was hoping for something like
nx = re.compile('regex')
if x = nx.search(text):
funCall(