Re: Behavior of the for-else construct

2022-03-09 Thread Peter J. Holzer
On 2022-03-07 06:00:57 -0800, Grant Edwards wrote: > On 2022-03-07, Peter J. Holzer wrote: > > On 2022-03-06 18:34:39 -0800, Grant Edwards wrote: > >> On 2022-03-06, Avi Gross via Python-list wrote: > >> > Python is named after a snake right? > >> > >> No. It's named after a comedy troupe. > > >

Re: Behavior of the for-else construct

2022-03-07 Thread Antoon Pardon
Op 4/03/2022 om 02:08 schreef Avi Gross via Python-list: If Python was being designed TODAY, I wonder if a larger set of key words would be marked as RESERVED for future expansion including ORELSE and even NEVERTHELESS. I think a better solution would be to have reserved words written lette

Non sequitur: Changing subject line... WAS: Behavior of the for-else construct

2022-03-07 Thread Dennis Lee Bieber
On Mon, 7 Mar 2022 18:07:42 +, "Schachner, Joseph" declaimed the following: >Can someone please change the topic of this thread? No longer about for-else. > Pretty much anyone can change the subject of the message when replying. But if one is using a threa

RE: Behavior of the for-else construct

2022-03-07 Thread Schachner, Joseph
Can someone please change the topic of this thread? No longer about for-else. Teledyne Confidential; Commercially Sensitive Business Data -Original Message- From: Dennis Lee Bieber Sent: Sunday, March 6, 2022 1:29 PM To: python-list@python.org Subject: Re: Behavior of the for-else

Re: Behavior of the for-else construct

2022-03-07 Thread Grant Edwards
On 2022-03-07, Peter J. Holzer wrote: > On 2022-03-06 18:34:39 -0800, Grant Edwards wrote: >> On 2022-03-06, Avi Gross via Python-list wrote: >> > Python is named after a snake right? >> >> No. It's named after a comedy troupe. > > He actually wrote that two sentences later. Yes, I missed that.

Re: Behavior of the for-else construct

2022-03-06 Thread Peter J. Holzer
On 2022-03-06 18:34:39 -0800, Grant Edwards wrote: > On 2022-03-06, Avi Gross via Python-list wrote: > > Python is named after a snake right? > > No. It's named after a comedy troupe. He actually wrote that two sentences later. hp -- _ | Peter J. Holzer| Story must make more s

Re: Behavior of the for-else construct

2022-03-06 Thread Grant Edwards
On 2022-03-06, Avi Gross via Python-list wrote: > Python is named after a snake right? No. It's named after a comedy troupe. -- Grant -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-06 Thread Dennis Lee Bieber
On Sun, 6 Mar 2022 17:39:51 +0100, "Peter J. Holzer" declaimed the following: > >(* *) for comments was actually pretty commonly used - maybe because it >stands out more than { }. I don't know if I've ever seen (. .) instead >of [ ]. > Or some terminals provided [ ] but not { }

Re: Behavior of the for-else construct

2022-03-06 Thread Chris Angelico
On Mon, 7 Mar 2022 at 09:51, Avi Gross via Python-list wrote: > > >>> > Pascal versus PASCAL versus pascal (not versus paschal) and > Perl versus PERL versus perl (not versus pearl) > > seems to be a topic. > <<< > > The nitpickers here are irrelevant. I happen to know how things are formally > s

Re: Behavior of the for-else construct

2022-03-06 Thread Avi Gross via Python-list
orrect, it has a proper spelling. But following that reasoning, why does anyone give an email address of john.sm...@gmail.com or jane...@yahoo.com instead of ...? -Original Message- From: Peter J. Holzer To: python-list@python.org Sent: Sun, Mar 6, 2022 12:48 pm Subject: Re: Behavior

Re: Behavior of the for-else construct

2022-03-06 Thread Peter J. Holzer
On 2022-03-06 09:29:19 -0800, Grant Edwards wrote: > On 2022-03-05, Avi Gross via Python-list wrote: > > I am not sure how we end up conversing about PASCAL on a Python > > forum. > > [...] > > I paid no attention to where PASCAL was being used other than I did > > much of my grad school work in P

Re: Behavior of the for-else construct

2022-03-06 Thread Grant Edwards
On 2022-03-05, Avi Gross via Python-list wrote: > I am not sure how we end up conversing about PASCAL on a Python > forum. > [...] > I paid no attention to where PASCAL was being used other than I did > much of my grad school work in PASCAL [...] It's "Pascal". It's not an acronym. It's a guy's

Re: Behavior of the for-else construct

2022-03-06 Thread Peter J. Holzer
On 2022-03-05 14:25:35 -0500, Dennis Lee Bieber wrote: > On Sat, 5 Mar 2022 12:39:36 -0600, "Michael F. Stemper" > declaimed the following: > >... especially Pascal, which was probably bigger in Germany and Austria > >in the 1980s than was C. > > Pascal also defined alternate representation

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
and other languages to undergrads ;-) -Original Message- From: Dennis Lee Bieber To: python-list@python.org Sent: Sat, Mar 5, 2022 7:00 pm Subject: Re: Behavior of the for-else construct On Sat, 5 Mar 2022 21:40:08 + (UTC), Avi Gross declaimed the following: >I am not sure how we end

Re: Behavior of the for-else construct

2022-03-05 Thread Dennis Lee Bieber
On Sat, 5 Mar 2022 21:40:08 + (UTC), Avi Gross declaimed the following: >I am not sure how we end up conversing about PASCAL on a Python forum. But it >is worth considering how people educated in aspects of Computer Science often >come from somewhat different background and how it flavors w

Re: Behavior of the for-else construct

2022-03-05 Thread Cameron Simpson
On 05Mar2022 17:48, Avi Gross wrote: >Since we still seem to be dreaming, I wonder when someone will suggest using >some variation of the new match statement. Ugh :-) But... What if break were implemented with an exception, like StopIteration but for interruption instead of stop? And for-loop

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
To: python-list@python.org Sent: Sat, Mar 5, 2022 1:39 pm Subject: Re: Behavior of the for-else construct On 04/03/2022 18.11, Peter J. Holzer wrote: > On 2022-03-04 23:47:09 +, Avi Gross via Python-list wrote: >> I am not sure a reply is needed, Peter, and what you say is true. But

Re: Behavior of the for-else construct

2022-03-05 Thread Michael F. Stemper
On 04/03/2022 18.11, Peter J. Holzer wrote: On 2022-03-04 23:47:09 +, Avi Gross via Python-list wrote: I am not sure a reply is needed, Peter, and what you say is true. But as you point out, when using a German keyboard, I would already have a way to enter symbols like ä, ö, ü and ß and no

Re: Behavior of the for-else construct

2022-03-05 Thread Dennis Lee Bieber
On Sat, 5 Mar 2022 12:39:36 -0600, "Michael F. Stemper" declaimed the following: >... especially Pascal, which was probably bigger in Germany and Austria >in the 1980s than was C. Pascal also defined alternate representations (per Jensen&Wirth) for some of those (and I don't recall ever

Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
my part of this endless conversation may have gone a bit beyond far enough and I await some new topics. -Original Message- From: Rob Cliffe via Python-list To: python-list@python.org Sent: Sat, Mar 5, 2022 7:15 am Subject: Re: Behavior of the for-else construct On 05/03/2022 01:15, Camer

Re: Behavior of the for-else construct

2022-03-05 Thread Rob Cliffe via Python-list
On 05/03/2022 01:15, Cameron Simpson wrote: I sort of wish it had both "used break" and "did not use break" branches, a bit like try/except/else. And "zero iterations". Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-05 Thread Peter J. Holzer
On 2022-03-05 00:25:44 +0100, Peter J. Holzer wrote: > On 2022-03-04 11:34:07 +1100, Chris Angelico wrote: > > What I'm hearing is that there are, broadly speaking, two types of > > programmers [1]: > > > > 1) Those who think about "for-else" as a searc

Re: Behavior of the for-else construct

2022-03-04 Thread Cameron Simpson
On 03Mar2022 14:24, computermaster360 wrote: >I want to make a little survey here. > >Do you find the for-else construct useful? Have you used it in >practice? Do you even know how it works, or that there is such a thing >in Python? I used Python for years before understanding th

Re: Behavior of the for-else construct

2022-03-04 Thread Peter J. Holzer
On 2022-03-04 23:47:09 +, Avi Gross via Python-list wrote: > I am not sure a reply is needed, Peter, and what you say is true. But > as you point out, when using a German keyboard, I would already have > a way to enter symbols like ä, ö, ü and ß and no reason not to include > them in variable

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
hon-list@python.org Sent: Fri, Mar 4, 2022 5:57 pm Subject: Re: Behavior of the for-else construct On 2022-03-04 00:38:22 +, Avi Gross via Python-list wrote: > I have seen major struggles to get other character sets into > languages. Any new language typically should have this built in from > s

Re: Behavior of the for-else construct

2022-03-04 Thread Chris Angelico
as implying something else. ELSE is ambiguous in the context it > > > is used. > > > > What I'm hearing is that there are, broadly speaking, two types of > > programmers [1]: > > > > 1) Those who think about "for-else" as a search tool and perf

Re: Behavior of the for-else construct

2022-03-04 Thread Peter J. Holzer
d. > > What I'm hearing is that there are, broadly speaking, two types of > programmers [1]: > > 1) Those who think about "for-else" as a search tool and perfectly > understand how it behaves > 2) Those who have an incorrect idea about what for-else is supposed to

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
To: python-list@python.org Sent: Fri, Mar 4, 2022 5:22 pm Subject: Re: Behavior of the for-else construct On 04/03/2022 20:52, Avi Gross via Python-list wrote: > > I have an observation about exception handling in general. Some people use > exceptions, including ones they create and t

Re: Behavior of the for-else construct

2022-03-04 Thread Peter J. Holzer
On 2022-03-04 14:04:48 -0600, Om Joshi wrote: > I'm not sure if anyone has mentioned it on this thread, but with > respect to your comment about adding either on.empty or a decorator, > the Django template syntax uses > > {% for x in iterator %} > {{ x }} > {% empty %} > Empty > {% endfor %} >

Re: Behavior of the for-else construct

2022-03-04 Thread Peter J. Holzer
On 2022-03-04 08:38:52 -0600, Tim Chase wrote: > On 2022-03-04 11:55, Chris Angelico wrote: > > In MS-DOS, it was perfectly possible to have spaces in file names > > DOS didn't allow space (0x20) in filenames unless you hacked it by > hex-editing your filesystem (which I may have done a couple tim

Re: Behavior of the for-else construct

2022-03-04 Thread Peter J. Holzer
On 2022-03-04 00:38:22 +, Avi Gross via Python-list wrote: > I have seen major struggles to get other character sets into > languages. Any new language typically should have this built in from > scratch and should consider adding non-ASCII characters into the mix. > Mathematicians often use lot

Re: Behavior of the for-else construct

2022-03-04 Thread Rob Cliffe via Python-list
On 04/03/2022 20:52, Avi Gross via Python-list wrote: I have an observation about exception handling in general. Some people use exceptions, including ones they create and throw, for a similar idea. You might for example try to use an exception if your first attempt fails that specifies try

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
lows something like: result = for ... That might return 0 or None if it was part of the language but it is not. Avi (my current first name) -Original Message- From: Om Joshi To: Avi Gross Cc: python-list Sent: Fri, Mar 4, 2022 3:04 pm Subject: Re: Behavior of the for-else constru

Re: Behavior of the for-else construct

2022-03-04 Thread Michael F. Stemper
On 03/03/2022 19.54, Rob Cliffe wrote: On 04/03/2022 01:44, Ethan Furman wrote: On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote: > There are three types of programmer: those that can count, and those that can't. Actually, there are 10 types of programmer:  those that can count in binary,

Re: Behavior of the for-else construct

2022-03-04 Thread Chris Angelico
On Sat, 5 Mar 2022 at 07:52, Avi Gross wrote: > > Chris, > > My example was precisely what to do when it is an empty closet: Does it correctly handle a closet with shirts in it, though? There's not a lot of point demonstrating an alternate use for the "else" clause when it is *absolutely identic

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
ye==4 after the loop. The above loop would leave it as aye==None which keeps it from being undefined. To decide if the loop ran at all would thus require further code such as: if aye == None: ... Which leads me right back to wondering why the sentinel approach is so bad! -----Origi

Re: Behavior of the for-else construct

2022-03-04 Thread 2QdxY4RzWzUUiLuE
On 2022-03-04 at 11:14:29 -0500, Dennis Lee Bieber wrote: > Try to tell the difference between > > afileand > afile > > when doing a directory listing. Easy: log in over a 110 baud modem, where the characters take almost as much time as the beep. ;-) -- https://mail.python

Re: Behavior of the for-else construct

2022-03-04 Thread Om Joshi
English or are more fluent in other languages. T may may be used to other > word orders for example. They may move verbs to the end of a sentence or > place adjectives or other modifiers after versus before a word and forget > about all the other games played where the same word

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
er versus before a word and forget about all the other games played where the same word means something completely different. To them ELSE may either mean nothing or the phrase IF ... ELSE may be said differently or adding a clause after the construct is not seen as natural. So was this way of doing FO

Re: Behavior of the for-else construct

2022-03-04 Thread Dennis Lee Bieber
On Fri, 4 Mar 2022 08:38:52 -0600, Tim Chase declaimed the following: >DOS didn't allow space (0x20) in filenames unless you hacked it by >hex-editing your filesystem (which I may have done a couple times). >However it did allow you to use 0xFF in filenames which *appeared* as >a space in most ch

Re: Behavior of the for-else construct

2022-03-04 Thread Chris Angelico
On Sat, 5 Mar 2022 at 03:44, Avi Gross via Python-list wrote: > > Dieter, > > Your use is creative albeit it is not "needed" since all it does is make sure > your variable is initialized to something, specifically None. > > So would this not do the same thing? > > eye = None > > for eye in ra

Re: Behavior of the for-else construct

2022-03-04 Thread Chris Angelico
On Sat, 5 Mar 2022 at 02:02, Tim Chase wrote: > > On 2022-03-04 11:55, Chris Angelico wrote: > > In MS-DOS, it was perfectly possible to have spaces in file names > > DOS didn't allow space (0x20) in filenames unless you hacked it by > hex-editing your filesystem (which I may have done a couple t

Re: Behavior of the for-else construct

2022-03-04 Thread Dieter Maurer
Avi Gross wrote at 2022-3-4 16:43 +: >Your use is creative albeit it is not "needed" since all it does is make sure >your variable is initialized to something, specifically None. > >So would this not do the same thing? > > eye = None > > for eye in range(0): > print(eye) > > eye It wo

Re: Behavior of the for-else construct

2022-03-04 Thread Avi Gross via Python-list
as discussed, you could do an IF statement to check if closet is empty but for iterators, it gets ... -Original Message- From: Dieter Maurer To: Rob Cliffe Cc: python-list@python.org Sent: Fri, Mar 4, 2022 2:12 am Subject: Re: Behavior of the for-else construct Rob Cliffe wrote at 2022-3

Re: Behavior of the for-else construct

2022-03-04 Thread Tim Chase
On 2022-03-04 11:55, Chris Angelico wrote: > In MS-DOS, it was perfectly possible to have spaces in file names DOS didn't allow space (0x20) in filenames unless you hacked it by hex-editing your filesystem (which I may have done a couple times). However it did allow you to use 0xFF in filenames wh

Re: Behavior of the for-else construct

2022-03-04 Thread Chris Angelico
On Fri, 4 Mar 2022 at 21:02, gene heskett wrote: > That makes the logic work, but who then cleans up the trash on the stack. > Thats a memory leak. > Not sure I follow? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-04 Thread gene heskett
On Friday, 4 March 2022 02:18:51 EST Chris Angelico wrote: > On Fri, 4 Mar 2022 at 18:13, Dieter Maurer wrote: > > Rob Cliffe wrote at 2022-3-4 00:13 +: > > >I find it so hard to remember what `for ... else` means that on the > > >very few occasions I have used

Re: Behavior of the for-else construct

2022-03-04 Thread Roel Schroeven
em") There's a parallel here. Since a for-else loop is basically useless without an if-break construct inside it, the else clause can be thought of as the else on a massive if/elif chain: if stuff[0].is_good: print("This item is good", stuff[0]) elif stuff[1].is_good:

Re: Behavior of the for-else construct

2022-03-04 Thread Roel Schroeven
Op 4/03/2022 om 8:18 schreef Chris Angelico: On Fri, 4 Mar 2022 at 18:13, Dieter Maurer wrote: > One of my use cases for `for - else` does not involve a `break`: > the initialization of the loop variable when the sequence is empty. > It is demonstrated by the following transscript: >

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 18:13, Dieter Maurer wrote: > > Rob Cliffe wrote at 2022-3-4 00:13 +: > >I find it so hard to remember what `for ... else` means that on the very > >few occasions I have used it, I ALWAYS put a comment alongside/below the > >`else` to remind

Re: Behavior of the for-else construct

2022-03-03 Thread Dieter Maurer
Rob Cliffe wrote at 2022-3-4 00:13 +: >I find it so hard to remember what `for ... else` means that on the very >few occasions I have used it, I ALWAYS put a comment alongside/below the >`else` to remind myself (and anyone else unfortunate enough to read my >code) what trig

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 14:37, Avi Gross via Python-list wrote: > > That is one way to look at it, Jach. Of course, a particular loop may have > multiple break statements each meaning something else. The current > implementation makes all of them jump to the same ELSE statement so in one > sense,

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
an ELSE dangling. -Original Message- From: Jach Feng To: python-list@python.org Sent: Thu, Mar 3, 2022 9:22 pm Subject: Re: Behavior of the for-else construct I never feel confused by "else" because I always think it in "break...else", not "for...else".

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 14:05, Avi Gross via Python-list wrote: > To answer something Chris said and was also mentioned here, I do not consider > language design to be easy let alone implementing it. Not at all. BUT I think > some changes can be straightforward. Having a symbol like a curly brace

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
hen you die and it simplifies. -Original Message- From: Rob Cliffe via Python-list To: python-list@python.org Sent: Thu, Mar 3, 2022 8:41 pm Subject: Re: Behavior of the for-else construct On 04/03/2022 00:38, Avi Gross via Python-list wrote: > Rob, > > I regularly code with l

Re: Behavior of the for-else construct

2022-03-03 Thread Jach Feng
I never feel confused by "else" because I always think it in "break...else", not "for...else". For those who always think in "for...else" deserves this confusion and it can't be just escaped by replacing with another magic word such as

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 00:55, Chris Angelico wrote: for victim in debtors: if victim.pay(up): continue if victim.late(): break or else: victim.sleep_with(fishes) If you mean "or else" to be synonymous with "else", then only the last debtor is killed, whether he has paid up or not, whic

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 01:44, Ethan Furman wrote: On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote: > There are three types of programmer: those that can count, and those that can't. Actually, there are 10 types of programmer:  those that can count in binary, and those that can't. 1, 10, many.

Re: Behavior of the for-else construct

2022-03-03 Thread Greg Ewing
On 4/03/22 1:55 pm, Chris Angelico wrote: It's much better to treat arguments as a vector of strings rather than a single string, as the start command tries to. It would be nice if you could, but as I understand it, Windows always passes arguments to a program as a single string, and then it's

Re: Behavior of the for-else construct

2022-03-03 Thread Ethan Furman
On 3/3/22 5:32 PM, Rob Cliffe via Python-list wrote: > There are three types of programmer: those that can count, and those that can't. Actually, there are 10 types of programmer: those that can count in binary, and those that can't. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/pyt

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
On 04/03/2022 00:43, Chris Angelico wrote: On Fri, 4 Mar 2022 at 11:14, Rob Cliffe via Python-list wrote: I find it so hard to remember what `for ... else` means that on the very few occasions I have used it, I ALWAYS put a comment alongside/below the `else` to remind myself (and anyone

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
ython-list To: python-list@python.org Sent: Thu, Mar 3, 2022 7:13 pm Subject: Re: Behavior of the for-else construct I find it so hard to remember what `for ... else` means that on the very few occasions I have used it, I ALWAYS put a comment alongside/below the `else` to remind myself (and anyo

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
e are, broadly speaking, two types of programmers [1]: 1) Those who think about "for-else" as a search tool and perfectly understand how it behaves 2) Those who have an incorrect idea about what for-else is supposed to do, don't understand it, and don't like it. Or those who have a

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
n NEVERTHELESS. -Original Message- From: Chris Angelico To: python-list@python.org Sent: Thu, Mar 3, 2022 7:34 pm Subject: Re: Behavior of the for-else construct On Fri, 4 Mar 2022 at 10:09, Avi Gross via Python-list wrote: > > The drumbeat I keep hearing is that some people h

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 11:39, Avi Gross via Python-list wrote: > > Rob, > > I regularly code with lots of comments like the one you describe, or mark the > end of a region that started on an earlier screen such as a deeply nested > construct. > > I have had problems though when I have shared such

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 11:14, Rob Cliffe via Python-list wrote: > > I find it so hard to remember what `for ... else` means that on the very > few occasions I have used it, I ALWAYS put a comment alongside/below the > `else` to remind myself (and anyone else unfortunate enough to re

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
Thu, Mar 3, 2022 7:13 pm Subject: Re: Behavior of the for-else construct I find it so hard to remember what `for ... else` means that on the very few occasions I have used it, I ALWAYS put a comment alongside/below the `else` to remind myself (and anyone else unfortunate enough to read my code)

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
of programmers [1]: 1) Those who think about "for-else" as a search tool and perfectly understand how it behaves 2) Those who have an incorrect idea about what for-else is supposed to do, don't understand it, and don't like it. You could easily make a similar point about a l

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
I find it so hard to remember what `for ... else` means that on the very few occasions I have used it, I ALWAYS put a comment alongside/below the `else` to remind myself (and anyone else unfortunate enough to read my code) what triggers it, e.g.     for item in search_list

Re: Behavior of the for-else construct

2022-03-03 Thread Avi Gross via Python-list
age must be added to sparingly and with so many requests, perhaps only a few non bug-fixes can seriously be considered. -Original Message- From: Akkana Peck To: python-list@python.org Sent: Thu, Mar 3, 2022 5:33 pm Subject: Re: Behavior of the for-else construct computermaster360 writes

Re: Behavior of the for-else construct

2022-03-03 Thread Akkana Peck
computermaster360 writes: > I want to make a little survey here. > > Do you find the for-else construct useful? No. > Have you used it in practice? Once or twice, but ended up removing it, see below. > Do you even know how it works, or that there is such a thing in Python? I

Re: Behavior of the for-else construct

2022-03-03 Thread Jon Ribbens via Python-list
On 2022-03-03, computermaster360 wrote: > Do you find the for-else construct useful? Have you used it in > practice? Yes, I use it frequently. > I have used it maybe once. My issue with this construct is that > calling the second block `else` doesn't make sense; a much mor

Re: Behavior of the for-else construct

2022-03-03 Thread Michael F. Stemper
On 03/03/2022 07.24, computermaster360 wrote: I want to make a little survey here. Do you find the for-else construct useful? Have you used it in practice? Do you even know how it works, or that there is such a thing in Python? I only found out about it within the last year or so. I've

Re: Behavior of the for-else construct

2022-03-03 Thread computermaster360
On Thu, 3 Mar 2022 at 18:25, Schachner, Joseph wrote: > I don't know what that would be. "finally" is available 😊 Write up a > feature request. Not sure if you mean `finally` seriously but I think that would about as confusing as the current `else`, if not even more 😅 Meanwhile, I found anoth

RE: Behavior of the for-else construct

2022-03-03 Thread Schachner, Joseph
re request. --- Joseph S. Teledyne Confidential; Commercially Sensitive Business Data -Original Message- From: computermaster360 Sent: Thursday, March 3, 2022 8:24 AM To: python-list@python.org Subject: Behavior of the for-else construct I want to make a little survey here. Do you fi

Re: Behavior of the for-else construct

2022-03-03 Thread Dieter Maurer
computermaster360 wrote at 2022-3-3 14:24 +0100: >Do you find the for-else construct useful? Yes. >Have you used it in practice? Yes -- https://mail.python.org/mailman/listinfo/python-list

Re: Behavior of the for-else construct

2022-03-03 Thread Rob Cliffe via Python-list
    if the loop was executed zero times but these have not been accepted. Best wishes Rob Cliffe On 03/03/2022 13:24, computermaster360 wrote: I want to make a little survey here. Do you find the for-else construct useful? Have you used it in practice? Do you even know how it works, or that there

Re: Behavior of the for-else construct

2022-03-03 Thread Roel Schroeven
Op 3/03/2022 om 14:24 schreef computermaster360: I want to make a little survey here. Do you find the for-else construct useful? Have you used it in practice? Do you even know how it works, or that there is such a thing in Python? - No, or at least not when balanced against the drawbacks as I

Re: Behavior of the for-else construct

2022-03-03 Thread Grant Edwards
On 2022-03-03, computermaster360 wrote: > Do you find the for-else construct useful? Yes. > Have you used it in practice? Yes. I don't use it often, but I do use it occasionally. However, I always have to look it up the docs to confirm the logic. I always feel like the els

Re: Behavior of the for-else construct

2022-03-03 Thread Tim Chase
On 2022-03-04 02:02, Chris Angelico wrote: >> I want to make a little survey here. >> >> Do you find the for-else construct useful? Have you used it in >> practice? Do you even know how it works, or that there is such a >> thing in Python? > > Yes, yes, and y

Re: Behavior of the for-else construct

2022-03-03 Thread Barry Scott
> On 3 Mar 2022, at 13:24, computermaster360 > wrote: > > I want to make a little survey here. > > Do you find the for-else construct useful? No. I always have to look up what condition the else fires on. > Have you used it in > practice? No. > Do you even

Re: Behavior of the for-else construct

2022-03-03 Thread Chris Angelico
On Fri, 4 Mar 2022 at 00:25, computermaster360 wrote: > > I want to make a little survey here. > > Do you find the for-else construct useful? Have you used it in > practice? Do you even know how it works, or that there is such a thing > in Python? Yes, yes, and yes-yes. It&

Re: Behavior of the for-else construct

2022-03-03 Thread Dan Stromberg
On Thu, Mar 3, 2022 at 5:24 AM computermaster360 < computermaster...@gmail.com> wrote: > I want to make a little survey here. > > Do you find the for-else construct useful? Have you used it in > practice? Do you even know how it works, or that there is such a thing > in Pytho

Behavior of the for-else construct

2022-03-03 Thread computermaster360
I want to make a little survey here. Do you find the for-else construct useful? Have you used it in practice? Do you even know how it works, or that there is such a thing in Python? I have used it maybe once. My issue with this construct is that calling the second block `else` doesn't make

Re: A use-case for for...else with no break

2017-11-03 Thread Steve D'Aprano
On Fri, 3 Nov 2017 09:13 pm, Serhiy Storchaka wrote: > What the interpreter or configuration do you use? The standard > interpreter uses '>>> ' as a prompt. I have this in my Python startup file: if (sys.version_info[0] >= 3 and os.name == 'posix' and os.environ['TERM'] in ['xterm', 'vt1

Re: A use-case for for...else with no break

2017-11-03 Thread Serhiy Storchaka
02.11.17 12:10, Steve D'Aprano пише: Occasionally it is useful to loop over a bunch of stuff in the interactive interpreter, printing them as you go on a single line: for x in something(): print(x, end='') If you do that, the prompt overwrites your output, and you get a mess: py> for x i

Re: A use-case for for...else with no break

2017-11-03 Thread Steve D'Aprano
f count == 60: print(' ', time.asctime()) count = 0 print('.', end='') expensive_time_consuming_process_that_might_take_minutes_or_hours(obj) count += 1 else: del count print() print("finished at", time.asctime()) Now honestly, do y

Re: A use-case for for...else with no break

2017-11-02 Thread Paul Rubin
Steve D'Aprano writes: > for x in something(): > print(x, end='') print(''.join(something())) -- https://mail.python.org/mailman/listinfo/python-list

Re: A use-case for for...else with no break

2017-11-02 Thread Terry Reedy
On 11/2/2017 8:53 PM, Steve D'Aprano wrote: On Fri, 3 Nov 2017 09:20 am, Terry Reedy wrote: This seems like a bug in how Python interacts with your console. On Windows, in Python started from an icon or in Command Prompt: >>> for c in 'abc': print(c, end='') ... abc>>> That's still unfortu

Re: A use-case for for...else with no break

2017-11-02 Thread Steve D'Aprano
On Fri, 3 Nov 2017 09:20 am, Terry Reedy wrote: > This seems like a bug in how Python interacts with your console. On > Windows, in Python started from an icon or in Command Prompt: > > >>> for c in 'abc': print(c, end='') > ... > abc>>> That's still unfortunate: the prompt is immediately afte

Re: A use-case for for...else with no break

2017-11-02 Thread Terry Reedy
7;') ... abc>>> IDLE adds \n if needed, so prompts always starts on a fresh line. >>> for x in 'abcdefgh': print(x, end='') abcdefgh >>> "For ... else" to the rescue! py> for char in "abcdefgh": ... print(char, end='') ... else: ... print() ... abcdefgh py> -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: A use-case for for...else with no break

2017-11-02 Thread Steve D'Aprano
On Thu, 2 Nov 2017 10:45 pm, Alberto Berti wrote: >>>>>> "Steve" == Steve D'Aprano writes: > > py> for x in "abcdefgh": > Steve> ... print(x, end='') > Steve> ... > py> efghpy> > > &g

Re: A use-case for for...else with no break

2017-11-02 Thread Alberto Berti
> "Wolfgang" == Wolfgang Maier > writes: Wolfgang> Try running it interactively and you'll see, Wolfgang> wolfgang I've tried but my muscolar memory failed me... i've issued a C-c C-c that usually would have sent the region of text to the interpreter session (when done from python

Re: A use-case for for...else with no break

2017-11-02 Thread Wolfgang Maier
On 11/02/2017 12:45 PM, Alberto Berti wrote: "Steve" == Steve D'Aprano writes: py> for x in "abcdefgh": Steve> ... print(x, end='') Steve> ... py> efghpy> Steve> "For ... else" to the rescue!

Re: A use-case for for...else with no break

2017-11-02 Thread Alberto Berti
>>>>> "Steve" == Steve D'Aprano writes: py> for x in "abcdefgh": Steve> ... print(x, end='') Steve> ... py> efghpy> Steve> "For ... else" to the rescue! py> for char in "abcdefgh&

A use-case for for...else with no break

2017-11-02 Thread Steve D'Aprano
;: ... print(x, end='') ... py> efghpy> "For ... else" to the rescue! py> for char in "abcdefgh": ... print(char, end='') ... else: ... print() ... abcdefgh py> -- Steve “Cheer up,” they said, “things could be worse.” So I cheered

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Michael Selik
On Wed, Jun 29, 2016 at 7:11 AM Victor Savu wrote: > Please let me know if you are interested in a more concrete case such as a > domain-specific application (I can think of progress bars, logging, > transfer rate statistics ...). > Yes, please. I'd like to compare the proposed syntax against th

Re: Language improvement: Get more from the `for .. else` clause

2016-06-29 Thread Victor Savu
Sure. Simple use-case: Decorate the yielded values and the return value of a generator. Right now, with `yield from` you can only decorate the return value, whereas with a for loop you can decorate the yielded values, but you sacrifice the returned value altogether. ``` def ret_decorator(target_g

Re: Language improvement: Get more from the `for .. else` clause

2016-06-27 Thread Michael Selik
On Mon, Jun 27, 2016 at 12:53 AM Victor Savu wrote: > capture the [StopIteration] value in the `else` statement of the `for` loop > I'm having trouble thinking of a case when this new feature is necessary. Can you show a more realistic example? -- https://mail.python.org/mailman/listinfo/python

Language improvement: Get more from the `for .. else` clause

2016-06-26 Thread Victor Savu
lause of the `for .. else` statement: Generators raise StopIteration on the return statement. The exception captures the return value. The `for` statement catches the `StopIteration` exception to know when to jump to the optional `else` statement, but discards the enclosed return

<    1   2   3   >