[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I see that this was already moved to the mailing list.  Am marking this as 
closed.  If the mail list discussion proves favorable, feel free to reopen.

--
nosy: +rhettinger
resolution:  -> later
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-18 Thread Vedran Čačić

Vedran Čačić  added the comment:

I completely agree that we should reject this, but you commit a very frequent 
mistake in programming try-expressions. The problem is, if the first option 
contains a NameError, second option will be executed.

It should be:

try: i001
except NameError: 
else: 

And similarly for break001. You see, dependent `else` is needed sometimes. But 
of course Guido already covered this. :-)

--
nosy: +veky

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think this should be closed as 'rejected'.

1. I am strongly opposed to giving keywords strongly context-dependent 
alternate meanings.  I also don't think that the proposal could be parsed.  
Currently, 'if' introduces a new, independent statement, and making it 
dependent is not backwards compatible.

2. The proposal is unnecessary as the conditions can already be detected, and 
being explicit is much more flexible than the proposal.

for i001 in iterable: pass  # i001 is a new local name.

try:
i001

except NameError:


for i in range(5):
if i > 3:
break001 = True  # New local.
break

try:
break001
< loop broke>
except NameError:
< loop exited normally>

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-10 Thread Eric V. Smith


Eric V. Smith  added the comment:

You should bring this up on the python-ideas mailing list so that it gets more 
visibility.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41272] New clause in FOR and WHILE instead of ELSE

2020-07-10 Thread catrudis


New submission from catrudis :

ELSE-clause in FOR and WHILE has unclear syntax. I suggest new clause instead:

if COND:
  ...
[elif COND:
  ...]
[else:
  ...]

This IF-clause like must be immediately after FOR- or WHILE-cycle (only comment 
allowed between). It looks like a regular IF, but COND is special.
COND may be "break", "pass" or "finally". "if break:" - if used break-operator 
to exit cycle. "if pass:" - cycle executed 0 times. "if finally:" - cycle 
executed 0 or more times ("pass-case"  is included in "finally-case"). For 
compatibility only "else:" means "if finally:".
It's compatible enhancement. No new keyword. There can be no combination 
"break", "pass" or "finally" after "if"/"elif:" in current version.

--
components: Interpreter Core
messages: 373479
nosy: catrudis
priority: normal
severity: normal
status: open
title: New clause in FOR and WHILE instead of ELSE
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com