Re: while expression feature proposal

Discussion in 'Python' started by Cameron Simpson, Oct 27, 2012.

  1. On 26Oct2012 16:48, Ian Kelly <> wrote:
    | On Fri, Oct 26, 2012 at 4:03 PM, Cameron Simpson <> 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.

    Cheers,
    --
    Cameron Simpson <>

    Every \item command in item_list must have an optional argument.
    - Leslie Lamport, LaTeX
     
    Cameron Simpson, Oct 27, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Loewenherz

    while expression feature proposal

    Dan Loewenherz, Oct 24, 2012, in forum: Python
    Replies:
    1
    Views:
    147
    Paul Rubin
    Oct 24, 2012
  2. Ian Kelly
    Replies:
    0
    Views:
    136
    Ian Kelly
    Oct 24, 2012
  3. Tim Chase
    Replies:
    0
    Views:
    153
    Tim Chase
    Oct 24, 2012
  4. Cameron Simpson

    Re: while expression feature proposal

    Cameron Simpson, Oct 24, 2012, in forum: Python
    Replies:
    6
    Views:
    165
    Thomas Rachel
    Oct 25, 2012
  5. Chris Angelico

    Re: while expression feature proposal

    Chris Angelico, Oct 24, 2012, in forum: Python
    Replies:
    0
    Views:
    180
    Chris Angelico
    Oct 24, 2012
Loading...

Share This Page