Re: assignment in if

2006-05-02 Thread Edward Elliott
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

Re: assignment in if

2006-05-02 Thread Edward Elliott
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

Re: assignment in if

2006-05-02 Thread Bruno Desthuilliers
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

Re: assignment in if

2006-05-02 Thread Edward Elliott
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

Re: assignment in if

2006-05-02 Thread Ben Caradoc-Davies
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

Re: assignment in if

2006-05-02 Thread Bruno Desthuilliers
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

Re: assignment in if

2006-05-02 Thread Roy Smith
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,

assignment in if

2006-05-02 Thread Gary Wessle
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(