On 2017-11-02, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > On Fri, 3 Nov 2017 12:39 am, Jon Ribbens wrote: >> Why would we want to make the language worse? It is fairly obvious >> what 'else' means, > > Yes, obvious and WRONG.
Nope, obvious and right. > for x in seq: > do_something() > else: > print("seq was empty") > > is an obvious, common and wrong interpretation. No, it's an obvious bug. You have a 'for...else' with no 'break'. Like I said, that should probably be a syntax error. >> whereas 'then' has an obvious meaning that is in >> fact the opposite of what it would actually do. > > Er... is today opposite day? Because 'then' describes precisely what it > actually does. No, 'then' describes the opposite of what it does. The word 'then' implies something that always happens next, whereas 'else' conveys the correct meaning, which is something that happens if the course of the preceding piece of code did not go as expected. > Perhaps before we continue, we should ask what you think for...else > and while...else statements do. Just to be sure we are all on the > same page here. I think they do what the Python Language Reference sections 8.2 and 8.3 say they do. >> It seems clear that 'else' is the correct word (or at least, far >> better than 'then'). > > Not clear at all. The 'for...else' block is a common source of > confusion, if it was clear what it did, people wouldn't so often get > it wrong. That might be an argument that it is imperfect. It doesn't even begin to constitute an argument that 'then' would be an improvement. >> Maybe the change should be that it is a syntax error to use a >> 'for/while...else' with no 'break'. > > Only if you want to make the experience of using Python in the interactive > interpreter worse. See my recent post: > > "A use-case for for...else with no break" Yes, I saw that. It's possible you are the only person in the world ever to have done that. It would not make the interactive interpreter 'worse' in the slightest for that silly trick to be lost. -- https://mail.python.org/mailman/listinfo/python-list