Loop-and-a-half (Re: Curious assignment behaviour)
Huaiyu Zhu
huaiyu at gauss.almadan.ibm.com
Mon Oct 15 19:59:16 EDT 2001
On Sat, 13 Oct 2001 10:59:38 +0200, Alex Martelli <aleax at aleax.it> wrote:
>Your approach is indeed far more general -- I just showed somewhat-clunky
>syntax that has the advantage of working right now (and ever since the Dawn
>of Python) when one is transliterating code from other languages (I
>wouldn't use it in code meant to be idiomatically Pythonic, or Pythonically
>idiomatic). However, the ability to have arbitrary statements as part of
>an "expression" may be TOO general for comfort -- right now I can rely on
>the fact that an expression can never rebind my local variables (and this
>for example makes eval usable where exec might not be), the generalization
>would take such guarantees away. A much more wary look at the trade-offs
>is therefore surely warranted.
Agreed generally. A clarification, though: the proposal does not allow
statements in expressions; it allows statements _between_ conditional
keywords and the corresponding expressions, like
while [ <statements> ; ] <expression> : <suite>
if [ <statements> ; ] <expression> : <suite>
The distinction between expression and statements is not diminished.
Huaiyu
More information about the Python-list
mailing list