[Python-ideas] Control Flow - Never Executed Loop Body

Sven R. Kunze srkunze at mail.de
Wed Mar 23 16:26:03 EDT 2016


On 23.03.2016 16:53, Andrew Barnert via Python-ideas wrote:
> On Mar 23, 2016, at 03:08, Michel Desmoulin <desmoulinmichel at gmail.com> wrote:
>
>>> But I think it is a coherent proposal, even if it's not one I like. :)
>> And what do you think about adding except clauses to if ? with ? while ?
> Well, they don't have the problem that for has (for is already implicitly handling a specific exception in a specific way; none of them are), so they're coherent even without a solution to that problem.

Could you describe what you mean by coherent?

> (With has the additional problem that it may not be immediately obvious on first glance whether the exit gets calls before or after the except clause, but if so, people can read the docs the first time they come across it and remember it after that.)
>
> But I also think they're even less necessary. They'd all be pure syntactic sugar for nesting the statement and a try/except, so we'd be making the language more complicated to learn and remember,

I completely disagree here.

> and encouraging more code that isn't backward compatible.

What exactly is the problem with that? Everything discussed on 
python-ideas would be 3.6+ anyway.

>   That's not a huge cost, but the benefit isn't very big either. For _really_ short cases, I think we want except expressions (PEP 463); for longish code, there's nothing wrong with an explicit try; the range for which hiding an implicit try inside if and while would really improve things is small enough that I don't think the benefit outweighs the cost.

That's your opinion here. And I find it interesting that others already 
have thought of the merging of try and if, for and while. It would 
definitely come in handy.

But I understand from your previous responses that you'd rather use 
Assembler because it is has no unneeded syntactic sugar. ;-) Just kidding.

> But maybe some good examples of realistic 3-liners that are significantly improved by the change would convince me (and, more importantly, convince a majority of the others who are skeptical), so I'll keep an open mind.

 From what I can see regarding the if-except proposal, the improvement 
would be constant. So, either you like it (as I do) or you don't see 
them as necessary (as you do).

There is nothing somebody can do to convince you that saving 1 line of 
code and 1 indentation level across 20 lines of code are good or bad.


Best,
Sven


More information about the Python-ideas mailing list