On 03/09/2014 07:16 PM, Jim J. Jewett wrote:

because I cannot imagine reading an embedded version of either of those
without having to mentally re-parse at the colon.  An example assuming
a precedence level that may not be what the PEP proposes:

     if myfunc(5, expr1 except expr2: expr3, "label"):
         for i in range(3, 3*max(data) except TypeError: 9, 3):
            ...

     if myfunc(5, (expr1 except expr2: expr3), "label"):
         for i in range(3, (3*max(data) except TypeError: 9), 3):
            ...

     if myfunc(5, expr1 except (expr2: expr3), "label"):
         for i in range(3, 3*max(data) except (TypeError: 9), 3):
            ...

     if myfunc(5, expr1 except (expr2: expr3), "label"):
         for i in range(3, 3*max(data) (except TypeError: 9), 3):
            ...

     if myfunc(5, expr1 except (expr3 if expr3), "label"):
         for i in range(3, 3*max(data) (except 9 if TypeError), 3):
            ...

     if myfunc(5, expr1 except (expr3 if expr3), "label"):
         for i in range(3, 3*max(data) except (9 if TypeError), 3):

     myarg = expr1 except (expr3 if expr2)
     if myfunc(5, myarg, "label"):
         limit = 3*max(data) except (9 if TypeError)
         for i in range(3, limit, 3):

Yes, I would prefer to create a variable naming those expressions,
but these are all still simple enough that I would expect to have
to read them.  (I like constructions that get ugly just a bit faster
than they get hard to understand.)  If I have to parse any of them,
the ones at the bottom are less difficult than the ones at the top.

I totally disagree. I found the second one the easiest to read, and outside a function call (or other complexity, the parens wouldn't be needed.

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to