[Python-Dev] for...else (original) (raw)
MRAB python at mrabarnett.plus.com
Wed Jul 26 19:36:22 EDT 2017
- Previous message (by thread): [Python-Dev] for...else
- Next message (by thread): [Python-Dev] for...else
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2017-07-26 23:55, Koos Zevenhoven wrote:
On Mon, Jul 24, 2017 at 7:14 PM, Steven D'Aprano <steve at pearwood.info_ _<mailto:steve at pearwood.info>>wrote:
Hello Kiuhnm, and welcome. On Mon, Jul 24, 2017 at 05:35:03PM +0200, Kiuhnm via Python-Dev wrote: > Hello, > > I think that the expression "for...else" or "while...else" is completely > counter-intuitive.
You may be right -- this has been discussed many, many times before. In my personal opinion, the best (and only accurate!) phrase would have been: for item in sequence: # block then: # block IMO, for item in sequence: # block nobreak: # or perhaps
if not break:
# block would be clearer (if the syntax is necessary at all). [snip]
You couldn't have "if not break:" because that would look like the start of an 'if' statement.
"nobreak" would introduce a new keyword, but "not break" wouldn't.
- Previous message (by thread): [Python-Dev] for...else
- Next message (by thread): [Python-Dev] for...else
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]