[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steven D'Aprano
On Sun, Jun 05, 2022 at 07:03:32AM +1000, Chris Angelico wrote: > How is redundancy fundamentally good, I don't know, you will have to ask somebody who is arguing that "redundancy is fundamentally good", which is not me. Redundancy can be either good or bad.

[Python-ideas] Re: Slice 'size' parameter (in the style of pairwise)

2022-06-04 Thread Cameron Simpson
On 02Jun2022 19:26, Kevin wrote: >I might be posting this prematurely, but I had an idea and wanted to float it. >Also, I'm new here so hopefully this is appropriate. > >How about augmenting slicing with an additional parameter 'size' (name chosen >to achieve alliteration; 'start', 'stop',

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Chris Angelico
On Sun, 5 Jun 2022 at 05:42, Steven D'Aprano wrote: > > Obviously sometimes it's unavoidable, but I don't think we can > > genuinely accept that the redundancy is *good*. > > You have convinced me! I'm now removing all my RAID devices! > > *wink* > > Would it have helped if I had said redundancy

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steven D'Aprano
On Sat, Jun 04, 2022 at 11:16:18PM +1000, Chris Angelico wrote: > > Redundancy is good: > > > > # Obviously, clearly wrong: > > spam, eggs, cheese = islice(myvalues, 5) > > Yes but which part is wrong? You're a professional programmer, so I am confident that you know the answer to that

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Chris Angelico
On Sat, 4 Jun 2022 at 22:16, Steven D'Aprano wrote: > > > On Sat, Jun 04, 2022 at 10:04:39AM -, Steve Jorgensen wrote: > > > OK. That's not terrible. It is a redundancy though, having to re-state > > the count of variables that are to be de-structured into on the left. > > Redundancy is good:

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steven D'Aprano
On Sat, Jun 04, 2022 at 10:04:39AM -, Steve Jorgensen wrote: > OK. That's not terrible. It is a redundancy though, having to re-state > the count of variables that are to be de-structured into on the left. Redundancy is good: # Obviously, clearly wrong: spam, eggs, cheese =

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steve Jorgensen
OK. That's not terrible. It is a redundancy though, having to re-state the count of variables that are to be de-structured into on the left. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Paul Moore
On Sat, 4 Jun 2022 at 09:39, Steve Jorgensen wrote: > > I was using the reading of lines from a file as a contrived example. There > are many other possible cases such as de-structuring from iterator such as > `itertools.repeat()` with no `count` argument which will generate values >

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steve Jorgensen
I was using the reading of lines from a file as a contrived example. There are many other possible cases such as de-structuring from iterator such as `itertools.repeat()` with no `count` argument which will generate values endlessly. ___ Python-ideas

[Python-ideas] Re: Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steven D'Aprano
On Sat, Jun 04, 2022 at 07:31:58AM -, Steve Jorgensen wrote: > A contrived use case: > > with open('document.txt', 'r') as io: > (line1, line2, *) = io > with open('document.txt', 'r') as io: line1 = io.readline() line2 = io.readline() It would be lovely if

[Python-ideas] Null wildcard in de-structuring to ignore remainder and stop iterating

2022-06-04 Thread Steve Jorgensen
A contrived use case: with open('document.txt', 'r') as io: (line1, line2, *) = io It is possible to kind of achieve the same result using `*_` except that would actually read all the lines from the file, even if we only want the first 2. …so I am suggesting that we use the bare

[Python-ideas] Re: Expand the try-expect syntax to support conditional expect block

2022-06-04 Thread Serhiy Storchaka
03.06.22 21:43, Nadav Misgav пише: should I try to implement this? seems there is some acceptance No core developer supported this feature. My example shows that there is a problem with the proposed syntax. It is too similar to the existing valid syntax, it will confuse both people and the