while expression feature proposal
cs at zip.com.au
Sat Oct 27 02:19:26 CEST 2012
On 26Oct2012 16:48, Ian Kelly <ian.g.kelly at gmail.com> wrote:
| On Fri, Oct 26, 2012 at 4:03 PM, Cameron Simpson <cs at zip.com.au> wrote:
| > It will work anywhere an expression is allowed, and superficially
| > doesn't break stuff that exists if "as" has the lowest precedence.
| Please, no. There is no need for it outside of while expressions, and
| anywhere else it's just going to be bad practice. Even if it's
| considered an expression, let's only allow it in while expressions.
We might just have to differ here.
| > It would probably mean folding the except/with "as" uses back into
| > expressions and out of the control-structural part of the grammar. I can't
| > see that that would actually break any existing code though - anyone else?
| Yes it would, because the meaning is a bit different in both of those
| cases. For except, the result of the expression (an exception class
| or tuple of classes) is not stored in the target; the exception
| *instance* is. Similarly for with, the result of the expression is
| not stored; the result of calling its __enter__ method is, which is
| often but not always the same thing.
Hmm. Good points. Possibly damning points.
except (E1, E2) as c as d:
anyone? I should hope not!
I may be back to +0 now:-( +0.5 for being able to get at partial
expression results somehow, -0.1 for the conflict above.
Cameron Simpson <cs at zip.com.au>
Every \item command in item_list must have an optional argument.
- Leslie Lamport, LaTeX
More information about the Python-list