replacing `else` with `then` in `for` and `try`

Steve D'Aprano steve+python at pearwood.info
Sun Nov 5 20:47:22 EST 2017


On Mon, 6 Nov 2017 01:39 am, Jon Ribbens wrote:

> On 2017-11-05, Steve D'Aprano <steve+python at pearwood.info> wrote:
>> On Sat, 4 Nov 2017 04:44 am, Jon Ribbens wrote:
>>> That conforms to my model. It's searching for the condition
>>> 'count > MAX_OBJECTS'.
>>
>> That's sounds to me that you are willing to call just about any test of a
>> condition inside a loop a "search". I don't think that's helpful. I think
>> it is mangling the word to the point it is meaningless.
> 
> You're entitled to your opinion, of course. I've provided you with a
> way of thinking about 'for...else' that makes its purpose and meaning
> intuitively obvious.

By definition, if people have to learn the "right mental model" (as opposed to
the one which just comes to them naturally) then there is nothing intuitive
about it.


[...]
>> I find the code useful. I shouldn't have to justify why it is useful to me,
>> but for the record it especially comes in handy when I've already typed out
>> a multi-line loop in the REPL, and only then realised that I'll need some
>> way to add an extra line at the end.
> 
> Just press up arrow to go back and edit the first line of your
> current input and insert an 'if 1:' as someone else suggested.

"Just press up arrow" -- and that will magically fill in the other 10 lines I
typed, will it?

Don't be so condescending. I know how to use up-arrow, and I even described
using it, which you cut out of your reply.

That's a pretty dishonest trick. You saw that I had already discussed the
limitations of using up-arrow to retrieve lines from command line history,
but rather than acknowledge that, you deleted my comment and added
condescending and useless "advice" to make me seem like I don't even know
something as simple as up-arrow.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list