assignment in if
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue May 2 23:00:36 EDT 2006
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 = re.compile('regex')
> if x = nx.search(text):
> funCall(text, x))
x = nx.search(text)
if x:
funCall(text, x)
More information about the Python-list
mailing list