[Python-ideas] except expression
Chris Angelico
rosuav at gmail.com
Tue Feb 18 17:06:15 CET 2014
More information about the Python-ideas mailing list
Tue Feb 18 17:06:15 CET 2014
- Previous message: [Python-ideas] except expression
- Next message: [Python-ideas] except expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Feb 19, 2014 at 2:56 AM, Paul Moore <p.f.moore at gmail.com> wrote: > On 18 February 2014 15:05, Chris Angelico <rosuav at gmail.com> wrote: >>> Well, yes and no. There are only 2 out of the 10 syntaxes originally >>> proposed in the PEP at the start of this thread that use a colon. I've >>> already pointed out that I don't like a colon, so assume I said >>> "except return 0" if you must :-) >> >> Whether it's a colon or another keyword, _something_ is necessary in >> there, if it's permissible to specify an exception type: >> >> sum(x[3] except IndexError 0 for x in list_of_tuples) >> sum(x[3] except 0 for x in list_of_tuples) >> >> How would you parse each of those, without a separator? > > With "return" as a separator. I said that above. Was I not clear? Sure. Sorry, got a bit of brain-fry at the moment; misinterpreted your last sentence three chevrons in. So yeah, that would be: sum(x[3] except IndexError return 0 for x in list_of_tuples) sum(x[3] except return 0 for x in list_of_tuples) > I remain less than happy with the colon notation, although I will > concede that the basic > > x[3] except IndexError: 0 > > form is not horrible - it just becomes horrible very, very fast when > people try to do anything more complicated than that. On the other > hand, none of the examples of *any* of the proposed syntaxes look > compelling to me - they are either too simple to be realistic, or so > complex that they should be factored out into multiple statements, in > my view. The same can be said for if/else and the short-circuiting uses of and/or, both of which have wide-spread support, and not just from folks like me who grew up with C. I'm currently working on finding a bunch of examples from the stdlib that could be translated. Will post them once I get the script sorted out. As it's currently 3AM, though, that means I need to fry up some bacon or something before I continue :) ChrisA
- Previous message: [Python-ideas] except expression
- Next message: [Python-ideas] except expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list