Re: for -- else: what was the motivation?

2022-11-05 Thread Peter J. Holzer
On 2022-10-22 15:04:58 +0200, Peter J. Holzer wrote: > On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > > http://literateprogramming.com/ > > > > > > Right. That's one of

Re: for -- else: what was the motivation?

2022-10-22 Thread Drew Pierson
the fuck? On Sat, Oct 22, 2022 at 9:06 AM Peter J. Holzer wrote: > On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > > http://literateprogramming.com/ > > > > > > Right.

Re: for -- else: what was the motivation?

2022-10-22 Thread Peter J. Holzer
On 2022-10-22 15:04:58 +0200, Peter J. Holzer wrote: > On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > > http://literateprogramming.com/ > > > > > > Right. That's one of

Re: for -- else: what was the motivation?

2022-10-22 Thread Peter J. Holzer
On 2022-10-19 12:10:52 +1100, Chris Angelico wrote: > On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > http://literateprogramming.com/ > > > > Right. That's one of the inspirations for my comment. > > > > But literate programming

Re: for -- else: what was the motivation?

2022-10-18 Thread Chris Angelico
On Wed, 19 Oct 2022 at 12:01, Peter J. Holzer wrote: > > On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > > which had special combinations for all the BASIC keywords). And if you > > > go this way, why not go a step further and dissociate the program from > > > its linear text

Re: for -- else: what was the motivation?

2022-10-18 Thread Peter J. Holzer
On 2022-10-17 09:25:00 +0200, Karsten Hilbert wrote: > > which had special combinations for all the BASIC keywords). And if you > > go this way, why not go a step further and dissociate the program from > > its linear text representation? Add footnotes, different views, > > hyperlinks, format

Re: for -- else: what was the motivation?

2022-10-17 Thread Robert Latest via Python-list
wrote: > I had another crazy thought that I AM NOT ASKING anyone to do. OK? > > I was wondering about a sort of catch method you could use that generates a > pseudo-signal only when the enclosed preceding loop exits normally as a > sort of way to handle the ELSE need without the use of a keyword

Re: for -- else: what was the motivation?

2022-10-17 Thread Dennis Lee Bieber
On Wed, 12 Oct 2022 23:19:39 +0100, Rob Cliffe declaimed the following: >I too have occasionally used for ... else.  It does have its uses. But >oh, how I wish it had been called something else more meaningful, >whether 'nobreak' or whatever.  It used to really confuse me.  Now I've

Aw: Re: for -- else: what was the motivation?

2022-10-17 Thread Karsten Hilbert
> which had special combinations for all the BASIC keywords). And if you > go this way, why not go a step further and dissociate the program from > its linear text representation? Add footnotes, different views, > hyperlinks, format mathematical expressions like formulas, etc.

Re: for -- else: what was the motivation?

2022-10-17 Thread Chris Angelico
On Mon, 17 Oct 2022 at 16:36, Antoon Pardon wrote: > > > > Op 17/10/2022 om 04:01 schreef Chris Angelico: > > On Mon, 17 Oct 2022 at 10:46, wrote: > >> My point Chris was that you can have a conversation where you are exploring > >> and not proposing. Brainstorming, perhaps. > > And my point is

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 17/10/2022 om 04:01 schreef Chris Angelico: On Mon, 17 Oct 2022 at 10:46, wrote: My point Chris was that you can have a conversation where you are exploring and not proposing. Brainstorming, perhaps. And my point is that either a proposal is a serious one that can expect serious

Re: for -- else: what was the motivation?

2022-10-16 Thread Chris Angelico
On Mon, 17 Oct 2022 at 10:46, wrote: > > My point Chris was that you can have a conversation where you are exploring > and not proposing. Brainstorming, perhaps. And my point is that either a proposal is a serious one that can expect serious discussion, or it isn't. Yes, I'm aware that it wasn't

RE: for -- else: what was the motivation?

2022-10-16 Thread avi.e.gross
To: python-list@python.org Subject: Re: for -- else: what was the motivation? On Mon, 17 Oct 2022 at 08:22, wrote: > I had another crazy thought that I AM NOT ASKING anyone to do. OK? > Here's another proposal: Let's ban you from this mailing list. Don't worry, I AM NOT ASKING anyone to do it. O

Re: for -- else: what was the motivation?

2022-10-16 Thread Chris Angelico
On Mon, 17 Oct 2022 at 08:22, wrote: > I had another crazy thought that I AM NOT ASKING anyone to do. OK? > Here's another proposal: Let's ban you from this mailing list. Don't worry, I AM NOT ASKING anyone to do it. OK? Do you see how ridiculous and pointless it is to have proposals with that

RE: for -- else: what was the motivation?

2022-10-16 Thread avi.e.gross
! -Original Message- From: Python-list On Behalf Of Antoon Pardon Sent: Sunday, October 16, 2022 1:38 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? Op 16/10/2022 om 19:03 schreef Chris Angelico: > On Mon, 17 Oct 2022 at 03:57, Antoon Pardon wrote: >&

Re: for -- else: what was the motivation?

2022-10-16 Thread Peter J. Holzer
On 2022-10-16 19:52:47 +0200, Antoon Pardon wrote: > Op 16/10/2022 om 19:01 schreef Peter J. Holzer: > > On 2022-10-16 12:17:39 +0200, Antoon Pardon wrote: > > > Op 16/10/2022 om 00:50 schreefavi.e.gr...@gmail.com: > > > > That might not easily solve this problem. But I wonder if reserving > > > >

Re: for -- else: what was the motivation?

2022-10-16 Thread Axy via Python-list
On 16/10/2022 18:43, Antoon Pardon wrote: Op 16/10/2022 om 17:03 schreef Avi Gross: Interesting idea, Anton. I would be interested in hearing more detail on how it would work. Although much of programming has been centered on the Latin alphabet and especially English, that may change. I can

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 19:01 schreef Peter J. Holzer: On 2022-10-16 12:17:39 +0200, Antoon Pardon wrote: Op 16/10/2022 om 00:50 schreefavi.e.gr...@gmail.com: That might not easily solve this problem. But I wonder if reserving some kind of prefix might help, so anything like extension.0nNoBreak

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 17:03 schreef Avi Gross: Interesting idea, Anton. I would be interested in hearing more detail on how it would work. Although much of programming has been centered on the Latin alphabet and especially English, that may change. I can imagine a customized compiler or

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 19:03 schreef Chris Angelico: On Mon, 17 Oct 2022 at 03:57, Antoon Pardon wrote: Op 16/10/2022 om 17:05 schreef Chris Angelico: On Sun, 16 Oct 2022 at 22:47, Antoon Pardon wrote: Why would I need good luck? I expressed an idea and you didn't like it. That won't affect

Re: for -- else: what was the motivation?

2022-10-16 Thread MRAB
hon-list On Behalf Of Rob Cliffe via Python-list Sent: Wednesday, October 12, 2022 6:20 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? I too have occasionally used for ... else. It does have its uses. But oh, how I wish it had been called something else more

Re: for -- else: what was the motivation?

2022-10-16 Thread Chris Angelico
On Mon, 17 Oct 2022 at 03:57, Antoon Pardon wrote: > > > Op 16/10/2022 om 17:05 schreef Chris Angelico: > > On Sun, 16 Oct 2022 at 22:47, Antoon Pardon wrote: > >> Why would I need good luck? I expressed an idea and you didn't like it. > >> That won't affect my life in a meaningful way. > >

Re: for -- else: what was the motivation?

2022-10-16 Thread Peter J. Holzer
On 2022-10-16 12:17:39 +0200, Antoon Pardon wrote: > Op 16/10/2022 om 00:50 schreef avi.e.gr...@gmail.com: > > That might not easily solve this problem. But I wonder if reserving > > some kind of prefix might help, so anything like extension.0nNoBreak > > could be added to a loop as a final clause

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 17:05 schreef Chris Angelico: On Sun, 16 Oct 2022 at 22:47, Antoon Pardon wrote: Why would I need good luck? I expressed an idea and you didn't like it. That won't affect my life in a meaningful way. Well, with that attitude, it's not going to affect anyone else's life

Re: for -- else: what was the motivation?

2022-10-16 Thread Chris Angelico
On Sun, 16 Oct 2022 at 22:47, Antoon Pardon wrote: > > > > Op 16/10/2022 om 13:03 schreef Chris Angelico: > > On Sun, 16 Oct 2022 at 21:19, Antoon Pardon wrote: > > > >> My idea would be to reserve different unicode blocks for the keywords > >> and the identifiers. e.g. We could reserve the

Re: for -- else: what was the motivation?

2022-10-16 Thread Avi Gross
Interesting idea, Anton. I would be interested in hearing more detail on how it would work. Although much of programming has been centered on the Latin alphabet and especially English, that may change. I can imagine a customized compiler or interpreter that uses key words in the local language

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 13:03 schreef Chris Angelico: On Sun, 16 Oct 2022 at 21:19, Antoon Pardon wrote: My idea would be to reserve different unicode blocks for the keywords and the identifiers. e.g. We could reserve the mathematical alphanumeric block for keywords and all other letters and

Re: for -- else: what was the motivation?

2022-10-16 Thread Chris Angelico
On Sun, 16 Oct 2022 at 21:19, Antoon Pardon wrote: > > Op 16/10/2022 om 00:50 schreef avi.e.gr...@gmail.com: > > This has been discussed so often precisely because I swear NO CHOICE of > > keyword would satisfy everybody! Most languages start with designated > > keywords and some reserve a few

Re: for -- else: what was the motivation?

2022-10-16 Thread Antoon Pardon
Op 16/10/2022 om 00:50 schreef avi.e.gr...@gmail.com: This has been discussed so often precisely because I swear NO CHOICE of keyword would satisfy everybody! Most languages start with designated keywords and some reserve a few for later use. But then things can get frozen in place to avoid

RE: for -- else: what was the motivation?

2022-10-15 Thread avi.e.gross
d of sorts. -Original Message- From: Python-list On Behalf Of Rob Cliffe via Python-list Sent: Wednesday, October 12, 2022 6:20 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? I too have occasionally used for ... else. It does have its uses. But oh, h

Re: for -- else: what was the motivation?

2022-10-15 Thread Grant Edwards
On 2022-10-12, Rob Cliffe via Python-list wrote: > I too have occasionally used for ... else.  It does have its uses. But > oh, how I wish it had been called something else more meaningful, > whether 'nobreak' or whatever. I use it a few times year. I have to look it up in the documentation

Re: for -- else: what was the motivation?

2022-10-14 Thread Rob Cliffe via Python-list
und in {lfile}") I think there are other places I could be using it, but honestly I tend to forget it’s available. From: Python-list on behalf of Stefan Ram Date: Wednesday, October 12, 2022 at 2:22 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attent

Re: for -- else: what was the motivation?

2022-10-12 Thread dn
On 11/10/2022 02.13, Grant Edwards wrote: On 2022-10-10, Chris Angelico wrote: On Mon, 10 Oct 2022 at 11:52, MRAB wrote: On 2022-10-10 00:40, dn wrote: On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: "shortest block first" Have never heard this advice before. Kind-of

Re: for -- else: what was the motivation?

2022-10-12 Thread Peter J. Holzer
On 2022-10-10 16:48:04 +, Robert Latest via Python-list wrote: > Axy wrote: > >> Also not really a justification for "shortest block first". Wanting > >> some elaboration on that. What's the value in it? > > > > Well, the value is productivity. No need to save puzzles "what this > > hanging

Re: for -- else: what was the motivation?

2022-10-12 Thread Peter J. Holzer
On 2022-10-10 10:11:10 +, Stefan Ram wrote: > I would not use tabs in source code as they are not > displayed in the same way everywhere. Some would argue that this is a feature. Different people prefer different indentation widths. Using a single tab character for an indentation level

Re: for -- else: what was the motivation?

2022-10-12 Thread Weatherby,Gerard
honestly I tend to forget it’s available. From: Python-list on behalf of Stefan Ram Date: Wednesday, October 12, 2022 at 2:22 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attention: This is an external email. Use caution responding, opening attachments o

Re: for -- else: what was the motivation?

2022-10-11 Thread Axy via Python-list
On 10/10/2022 06:15, avi.e.gr...@gmail.com wrote: Chris, a short(er) answer to your addition below. I did not at first share your perception but maybe do now. If the argument was that ELSE and other constructs like FINALLY or CATCH are horrible because they follow other code and important

Re: for -- else: what was the motivation?

2022-10-11 Thread Grant Edwards
On 2022-10-11, wrote: > But is that native python or some extension where "|" has been modified to > mean something other than a form of OR in some places? The latter. > What module do you need to load to make that happen? The provided link is for a page that shows the module and explains

Re: for -- else: what was the motivation?

2022-10-11 Thread dn
On 10/10/2022 16.19, avi.e.gr...@gmail.com wrote: I won't reply to everything Dave says and especially not the parts I fully agree with. I think in many situations in life there is no ONE way to do things so most advice is heuristic at best and many exceptions may exist depending on your

RE: for -- else: what was the motivation?

2022-10-11 Thread avi.e.gross
ideas of "pipelines" are equally pythonic and some may really be rather foreign to many programmers, at least until they catch on. Avi -Original Message- From: Python-list On Behalf Of Antoon Pardon Sent: Tuesday, October 11, 2022 10:30 AM To: python-list@python.org Subject: R

Re: for -- else: what was the motivation?

2022-10-11 Thread Antoon Pardon
Op 10/10/2022 om 04:38 schreef avi.e.gr...@gmail.com: [This is an answer for Peter and can easily be skipped by those who know or have no wish to.] Strictly speaking Peter, the word "pipe" may not mean quite something in Python but other concepts like chaining may be better. The original

Re: for -- else: what was the motivation?

2022-10-10 Thread Michael F. Stemper
On 09/10/2022 15.02, Peter J. Holzer wrote: On 2022-10-09 15:32:13 -0400, Avi Gross wrote: and of course no pipelines. Since you've now used that term repeatedly: What is a pipeline in Python? Could it be what's discussed starting on page 35 of this presentation?

Re: for -- else: what was the motivation?

2022-10-10 Thread Robert Latest via Python-list
Axy wrote: >> Also not really a justification for "shortest block first". Wanting >> some elaboration on that. What's the value in it? > > Well, the value is productivity. No need to save puzzles "what this > hanging else belongs to?" If you find yourself asking that question, the if-block is

Re: for -- else: what was the motivation?

2022-10-10 Thread Chris Angelico
On Tue, 11 Oct 2022 at 08:55, Robert Latest via Python-list wrote: > > Chris Angelico wrote: > > Yes, I'm aware that code readability becomes irrelevant for > > short-duration projects. Beside the point. I'm wondering how important > > it really is to have the shortest block first. > > I usually

Re: for -- else: what was the motivation?

2022-10-10 Thread Robert Latest via Python-list
Grant Edwards wrote: > I've followed that advice for several decades. I find it much easier > to read code that's organized that way -- particularly when the > difference in block sizes is large (e.g. the first block is one line, > and the second is a a hundred). If any conditionally executed

Re: for -- else: what was the motivation?

2022-10-10 Thread Jach Feng
Axy 在 2022年10月10日 星期一下午5:55:29 [UTC+8] 的信中寫道: > On 09/10/2022 03:33, Jach Feng wrote: > > The else is always coming with the break, not the for. > However, the compiler does not complain. Sure, the compiler will not complain even in a IOCCC contest:-) > > but the [for...else] is insane. > Not

Re: for -- else: what was the motivation?

2022-10-10 Thread Robert Latest via Python-list
Chris Angelico wrote: > Yes, I'm aware that code readability becomes irrelevant for > short-duration projects. Beside the point. I'm wondering how important > it really is to have the shortest block first. I usually put the most expected / frequent / not negated block first if the whole if/else

Re: for -- else: what was the motivation?

2022-10-10 Thread Jon Ribbens via Python-list
On 2022-10-10, Calvin Spealman wrote: > On Sat, Oct 8, 2022 at 5:35 PM rbowman wrote: >> On 10/7/22 21:32, Axy wrote: >> > So, seriously, why they needed else if the following pieces produce same >> > result? Does anyone know or remember their motivation? >> >> In real scenarios there would be

RE: for -- else: what was the motivation?

2022-10-10 Thread avi.e.gross
y, October 10, 2022 at 1:10 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** > On 10/10/2022 15:52, Weatherby,Gerard wrote: >> I wonder if for/e

Re: for -- else: what was the motivation?

2022-10-10 Thread Peter J. Holzer
On 2022-10-09 22:38:28 -0400, avi.e.gr...@gmail.com wrote: > [This is an answer for Peter and can easily be skipped by those who know or > have no wish to.] > > Strictly speaking Peter, the word "pipe" may not mean quite something in > Python but other concepts like chaining may be better. > >

Re: for -- else: what was the motivation?

2022-10-10 Thread Peter J. Holzer
On 2022-10-10 12:40:44 +1300, dn wrote: > On 10/10/2022 05.56, Peter J. Holzer wrote: > > On 2022-10-09 12:18:09 -0400, Avi Gross wrote: > > > Some would argue for a rule related to efficiency of execution. When you > > > have multiple blocks as in an if-else or case statement with multiple > > >

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
On 10/10/2022 19:25, Weatherby,Gerard wrote: pylint, at least, provides a warning: fe.py:4:0: W0120: Else clause on loop without a break statement (useless-else-on-loop) I'm using flake8, it does not, alas. Axy. -- https://mail.python.org/mailman/listinfo/python-list

Re: for -- else: what was the motivation?

2022-10-10 Thread Weatherby,Gerard
October 10, 2022 at 1:10 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** > On 10/10/2022 15:52, Weatherby,Gerard wrote: >> I wonder if for/else c

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
On 10/10/2022 15:52, Weatherby,Gerard wrote: I wonder if for/else could have been less confusing if it was referred to as for-break-else and if the else clause was only valid syntax if the for loop actually contained a break statement in the first place. Sounds reasonable. It would be

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
at 10:38 AM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On Sat, Oct 8, 2022 at 5:35 PM rbowman wrote: On 10/7/22 21:32, Axy wrote: So, seriously

Re: for -- else: what was the motivation?

2022-10-10 Thread Weatherby,Gerard
: Re: for -- else: what was the motivation? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** On Sat, Oct 8, 2022 at 5:35 PM rbowman wrote: > On 10/7/22 21:32, Axy wrote: > > So, seriously, why they needed else if the followi

Re: for -- else: what was the motivation?

2022-10-10 Thread Calvin Spealman
On Sat, Oct 8, 2022 at 5:35 PM rbowman wrote: > On 10/7/22 21:32, Axy wrote: > > So, seriously, why they needed else if the following pieces produce same > > result? Does anyone know or remember their motivation? > > In real scenarios there would be more logic in the for block that would > meet

Re: for -- else: what was the motivation?

2022-10-10 Thread Weatherby,Gerard
try: open(disk) except: error(“Can’t open disk”) lots of things From: Python-list on behalf of Karsten Hilbert Date: Monday, October 10, 2022 at 5:46 AM To: python-list@python.org Subject: Re: for -- else: what was the motivation? *** Attention

Re: for -- else: what was the motivation?

2022-10-10 Thread Grant Edwards
On 2022-10-10, Chris Angelico wrote: > On Mon, 10 Oct 2022 at 11:52, MRAB wrote: >> >> On 2022-10-10 00:40, dn wrote: >> > On Sun, 9 Oct 2022 at 15:39, Axy via Python-list >> > wrote: >> > >> >> "shortest block first" >> > >> > Have never heard this advice before. Kind-of rankled with me, as it

Re: for -- else: what was the motivation?

2022-10-10 Thread Chris Angelico
On Mon, 10 Oct 2022 at 22:37, Axy via Python-list wrote: > > > On 10/10/2022 12:24, Chris Angelico wrote: > > On Mon, 10 Oct 2022 at 21:57, Axy via Python-list > > wrote: > >> > >>> Not sure what you mean, but a for-else without a break is quite > >>> useless. What exactly ARE you arguing here?

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
On 10/10/2022 12:24, Chris Angelico wrote: On Mon, 10 Oct 2022 at 21:57, Axy via Python-list wrote: Not sure what you mean, but a for-else without a break is quite useless. What exactly ARE you arguing here? The else is associated with the break to the exact extent that one is essential

Re: for -- else: what was the motivation?

2022-10-10 Thread Chris Angelico
On Mon, 10 Oct 2022 at 21:57, Axy via Python-list wrote: > > > > Not sure what you mean, but a for-else without a break is quite > > useless. What exactly ARE you arguing here? > > > > The else is associated with the break to the exact extent that one is > > essential to the other's value. > >

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
Not sure what you mean, but a for-else without a break is quite useless. What exactly ARE you arguing here? The else is associated with the break to the exact extent that one is essential to the other's value. I'm not arguing. That was just for the record, how things are done in Python.

Re: for -- else: what was the motivation?

2022-10-10 Thread Chris Angelico
On Mon, 10 Oct 2022 at 20:56, Axy via Python-list wrote: > > > The else is always coming with the break, not the for. > However, the compiler does not complain. > > There are [for ...], [for...break...], and[for...break...else], > > That's implied and contradicts Zen of Python, I think. If

Re: for -- else: what was the motivation?

2022-10-10 Thread Chris Angelico
On Mon, 10 Oct 2022 at 20:46, Karsten Hilbert wrote: > > Am Sun, Oct 09, 2022 at 09:58:14AM + schrieb Stefan Ram: > > > I often follow this rule. For me, it's about readability. Compare: > > > > if not open( disk ): > > error( "Can't open disk" ) > > else: > > printf( "now imagine

Re: for -- else: what was the motivation?

2022-10-10 Thread Axy via Python-list
On 09/10/2022 03:33, Jach Feng wrote: Axy 在 2022年10月8日 星期� �上午11:39:44 [UTC+8] 的信中寫道: Hi there, this is rather a philosophical question, but I assume I miss something. I don't remember I ever used else clause for years I was with python and my expectation was it executed only if the the main

Re: for -- else: what was the motivation?

2022-10-10 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 09:58:14AM + schrieb Stefan Ram: > I often follow this rule. For me, it's about readability. Compare: > > if not open( disk ): > error( "Can't open disk" ) > else: > printf( "now imagine there's some larger block here" ) ... ad infinitum

Re: for -- else: what was the motivation?

2022-10-10 Thread Jach Feng
Axy 在 2022年10月8日 星期六上午11:39:44 [UTC+8] 的信中寫道: > Hi there, > > this is rather a philosophical question, but I assume I miss something. > I don't remember I ever used else clause for years I was with python and > my expectation was it executed only if the the main body was never run. > Ha-ha! I

Re: for -- else: what was the motivation?

2022-10-10 Thread rbowman
On 10/8/22 22:37, Axy wrote: Python is awesome because it's semantic is clear for the majority, but there are places that look odd. In case of "for", "else" looks logically tied with "for" clause, but actually it is not. It's tied with "break" statement and I overlooked that even after

RE: for -- else: what was the motivation?

2022-10-09 Thread avi.e.gross
Of Chris Angelico Sent: Monday, October 10, 2022 12:21 AM To: python-list@python.org Subject: Re: for -- else: what was the motivation? On Mon, 10 Oct 2022 at 14:59, wrote: > > >>>Which is more disparaging: "I couldn't find anyone suggesting this" > >>>or > &

Re: for -- else: what was the motivation?

2022-10-09 Thread Chris Angelico
On Mon, 10 Oct 2022 at 14:59, wrote: > > >>>Which is more disparaging: "I couldn't find anyone suggesting this" or > "The only place I could find it was a PHP style guide"? > >>>ChrisA > > Chris, > > If someone says they heard something from their own personal guru, people > often do not feel

RE: for -- else: what was the motivation?

2022-10-09 Thread avi.e.gross
>>>Which is more disparaging: "I couldn't find anyone suggesting this" or "The only place I could find it was a PHP style guide"? >>>ChrisA Chris, If someone says they heard something from their own personal guru, people often do not feel threatened or argue. I often am told nutrition or medical

RE: for -- else: what was the motivation?

2022-10-09 Thread avi.e.gross
hon-list@python.org Subject: Re: for -- else: what was the motivation? On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: > "shortest block first" Have never heard this advice before. Kind-of rankled with me, as it did for others. Enquiring minds want to know... Playe

RE: for -- else: what was the motivation?

2022-10-09 Thread avi.e.gross
eter J. Holzer Sent: Sunday, October 9, 2022 4:02 PM To: python-list@python.org Subject: Re: for -- else: what was the motivation? On 2022-10-09 15:32:13 -0400, Avi Gross wrote: > and of course no pipelines. Since you've now used that term repeatedly: What is a pipeline in

Re: for -- else: what was the motivation?

2022-10-09 Thread Chris Angelico
On Mon, 10 Oct 2022 at 11:52, MRAB wrote: > > On 2022-10-10 00:40, dn wrote: > > On Sun, 9 Oct 2022 at 15:39, Axy via Python-list > > wrote: > > > >> "shortest block first" > > > > Have never heard this advice before. Kind-of rankled with me, as it did > > for others. > > > > Enquiring minds

Re: for -- else: what was the motivation?

2022-10-09 Thread dn
On 10/10/2022 13.47, MRAB wrote: On 2022-10-10 00:40, dn wrote: On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: "shortest block first" Have never heard this advice before. Kind-of rankled with me, as it did for others. Enquiring minds want to know... Played Duck, duck, go on

Re: for -- else: what was the motivation?

2022-10-09 Thread MRAB
On 2022-10-10 00:40, dn wrote: On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: "shortest block first" Have never heard this advice before. Kind-of rankled with me, as it did for others. Enquiring minds want to know... Played Duck, duck, go on this: zero hits amongst a pile of

Re: for -- else: what was the motivation?

2022-10-09 Thread dn
On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: "shortest block first" Have never heard this advice before. Kind-of rankled with me, as it did for others. Enquiring minds want to know... Played Duck, duck, go on this: zero hits amongst a pile of similar phrases - turns-out

Re: for -- else: what was the motivation?

2022-10-09 Thread Peter J. Holzer
On 2022-10-09 15:32:13 -0400, Avi Gross wrote: > and of course no pipelines. Since you've now used that term repeatedly: What is a pipeline in Python? hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |

Re: for -- else: what was the motivation?

2022-10-09 Thread Avi Gross
Peter, There can be excellent reasons to undo a pipeline like I described. I often write it carefully in smaller chunks while debugging and make it more elegant later ... But someone amused me by explaining they were going to let people believe the code was written by them so it had to fit their

Re: for -- else: what was the motivation?

2022-10-09 Thread Avi Gross
Fair enough, Chris. There may be some overlap with the size of code for the most common cases but sometimes the opposite as those may be more complex to deal with. A reality for many programmers today is to not micromanage too early as things are often fast enough and any tweaking is best done

Re: for -- else: what was the motivation?

2022-10-09 Thread Peter J. Holzer
On 2022-10-09 12:34:22 -0400, Avi Gross wrote: > I have seen programmers who have taken an elegant pipeline I have built > apart and made it into many lines of code reassignment the value of each > step to the same or different variables and other ways of lengthening or > obscuring my intent. I

Re: for -- else: what was the motivation?

2022-10-09 Thread Peter J. Holzer
On 2022-10-09 12:18:09 -0400, Avi Gross wrote: > Smallest code blocks first may be a more modern invention. > > Some would argue for a rule related to efficiency of execution. When you > have multiple blocks as in an if-else or case statement with multiple > choices, that you order the most

Re: for -- else: what was the motivation?

2022-10-09 Thread Axy via Python-list
Since many languages allow placing multiple statements on one line or spreading one over many lines, it seems that the number of lines in code can be adjusted. If I have a line like: Alpha, beta, gamma, delta = 1, 2, 3, 4 Could that be rewritten as 4 or more lines? Surely! Especially if

Re: for -- else: what was the motivation?

2022-10-09 Thread Chris Angelico
On Mon, 10 Oct 2022 at 03:46, Avi Gross wrote: > > Chris, I was not arguing that at all. Maybe not intentionally, but you did lend a lot of weight to that argument :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: for -- else: what was the motivation?

2022-10-09 Thread Avi Gross
Chris, I was not arguing that at all. I was saying some rationales about how to order choices exist based on ideas like efficiency or other considerations. Sometimes people are mistaken as something may take constant time as implemented. And yes, many rules have countless exceptions. For

Re: for -- else: what was the motivation?

2022-10-09 Thread Avi Gross
Since many languages allow placing multiple statements on one line or spreading one over many lines, it seems that the number of lines in code can be adjusted. If I have a line like: Alpha, beta, gamma, delta = 1, 2, 3, 4 Could that be rewritten as 4 or more lines? I have seen programmers who

Re: for -- else: what was the motivation?

2022-10-09 Thread Chris Angelico
On Mon, 10 Oct 2022 at 03:22, Avi Gross wrote: > > Smallest code blocks first may be a more modern invention. > > Some would argue for a rule related to efficiency of execution. When you > have multiple blocks as in an if-else or case statement with multiple > choices, that you order the most

Re: for -- else: what was the motivation?

2022-10-09 Thread Karsten Hilbert
Am Sun, Oct 09, 2022 at 05:37:59AM +0100 schrieb Axy via Python-list: > Python is awesome because it's semantic is clear for the majority, but there > are places > that look odd. In case of "for", "else" looks logically tied with "for" > clause, but > actually it is not. It's tied with "break"

Re: for -- else: what was the motivation?

2022-10-09 Thread Avi Gross
Smallest code blocks first may be a more modern invention. Some would argue for a rule related to efficiency of execution. When you have multiple blocks as in an if-else or case statement with multiple choices, that you order the most common cases first. Those shorten execution more often than

Re: for -- else: what was the motivation?

2022-10-09 Thread Michael Speer
>Well, the value is productivity. No need to save puzzles "what this >hanging else belongs to?" if you get to the point where it's hard to tell which else lines up with which if or for statement, I would suggest breaking things out into well-named helper functions rather than worrying over

Re: for -- else: what was the motivation?

2022-10-09 Thread Peter J. Holzer
On 2022-10-09 05:37:59 +0100, Axy via Python-list wrote: > Actually the reason I never used "else" was the violation of the rule > of beauty "shortest block first". That's a weird rule. I can see justifications for "most common case first" and "most special case first", but ordering the cases in

Re: for -- else: what was the motivation?

2022-10-09 Thread Axy via Python-list
Yes, I'm aware that code readability becomes irrelevant for short-duration projects. Beside the point. I'm wondering how important it really is to have the shortest block first. I also might be wrong in terminology, anyway, there are many rules that make programmer's life easier, described

Re: for -- else: what was the motivation?

2022-10-08 Thread Chris Angelico
On Sun, 9 Oct 2022 at 16:05, Axy via Python-list wrote: > > > On 09/10/2022 05:47, Chris Angelico wrote: > > On Sun, 9 Oct 2022 at 15:39, Axy via Python-list > > wrote: > >> Got it, thanks! > >> > >> Actually the reason I never used "else" was the violation of the rule of > >> beauty "shortest

Re: for -- else: what was the motivation?

2022-10-08 Thread Axy via Python-list
On 09/10/2022 05:47, Chris Angelico wrote: On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: Got it, thanks! Actually the reason I never used "else" was the violation of the rule of beauty "shortest block first". With if--else you can easily follow this rule by inverting "if"

Re: for -- else: what was the motivation?

2022-10-08 Thread Chris Angelico
On Sun, 9 Oct 2022 at 15:39, Axy via Python-list wrote: > > Got it, thanks! > > Actually the reason I never used "else" was the violation of the rule of > beauty "shortest block first". With if--else you can easily follow this > rule by inverting "if" expression, but with for--else you can't. The

Re: for -- else: what was the motivation?

2022-10-08 Thread Axy via Python-list
Got it, thanks! Actually the reason I never used "else" was the violation of the rule of beauty "shortest block first". With if--else you can easily follow this rule by inverting "if" expression, but with for--else you can't. The loop body of the simplest example is already three lines, in

Re: for -- else: what was the motivation?

2022-10-08 Thread rbowman
On 10/7/22 21:32, Axy wrote: So, seriously, why they needed else if the following pieces produce same result? Does anyone know or remember their motivation? In real scenarios there would be more logic in the for block that would meet a condition and break out of the loop. If the condition is

Re: for -- else: what was the motivation?

2022-10-07 Thread Dan Stromberg
The else is executed if you don't "break" out of the loop early. It cuts down on boolean flags. On Fri, Oct 7, 2022 at 8:40 PM Axy via Python-list wrote: > Hi there, > > this is rather a philosophical question, but I assume I miss something. > I don't remember I ever used else clause for years