[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread Ricky Teachey
On Thu, Aug 12, 2021 at 5:16 PM Steven D'Aprano wrote: > On Thu, Aug 12, 2021 at 09:57:06AM -0400, Ricky Teachey wrote: > > > This got me thinking just now: allowing ellipses instead of None for the > > first two arguments of the slice() constructor might be a neat idea. > > Like this? > > >>> ob

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread Steven D'Aprano
On Thu, Aug 12, 2021 at 09:57:06AM -0400, Ricky Teachey wrote: > This got me thinking just now: allowing ellipses instead of None for the > first two arguments of the slice() constructor might be a neat idea. Like this? >>> obj = slice(..., ..., 5) >>> print(obj) slice(Ellipsis, Ellipsis, 5) Th

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread 2QdxY4RzWzUUiLuE
On 2021-08-12 at 14:05:23 -, eloi.riv...@aquilenet.fr wrote: > This is how slices are used in the python standard library, indeed, > but that does not stop me from interpreting the slices as "inclusive > by default" in my library. The inconsistency with the rest of the > python standard libra

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread Chris Angelico
On Fri, Aug 13, 2021 at 12:00 AM Ricky Teachey wrote: > > On Thu, Aug 12, 2021 at 9:02 AM Calvin Spealman wrote: >> >> An alternative suggestion, which works today (... is a valid object called >> Ellipsis): >> >>Foobar.search( >> attr1="foo", >> attr2=[10, ...], >> a

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread eloi . rivard
Definitively not as short as what I suggested, but I love it. I think this is one of the cleanest way I can do right now. Thanks! ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread eloi . rivard
This is how slices are used in the python standard library, indeed, but that does not stop me from interpreting the slices as "inclusive by default" in my library. The inconsistency with the rest of the python standard library could be misleading, but I think maybe less than off-by-1 errors? Yo

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread Ricky Teachey
On Thu, Aug 12, 2021 at 9:02 AM Calvin Spealman wrote: > An alternative suggestion, which works today (... is a valid object called > Ellipsis): > >Foobar.search( > attr1="foo", > attr2=[10, ...], > attr3=[42, ..., 50] > ) > This got me thinking just now: allowing

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread 2QdxY4RzWzUUiLuE
On 2021-08-12 at 08:56:22 -, eloi.riv...@aquilenet.fr wrote: > Hi. I am working on a kinda-ORM library, which usage often implies to request > data within specific ranges: > > Foobar.search( > attr1="foo", > attr2=gt(10), > attr3=between(42, 50) > ) > > The

[Python-ideas] Re: slices syntactic sugar

2021-08-12 Thread Calvin Spealman
An alternative suggestion, which works today (... is a valid object called Ellipsis): Foobar.search( attr1="foo", attr2=[10, ...], attr3=[42, ..., 50] ) On Thu, Aug 12, 2021 at 8:44 AM wrote: > Hi. I am working on a kinda-ORM library, which usage often implies to

[Python-ideas] slices syntactic sugar

2021-08-12 Thread eloi . rivard
Hi. I am working on a kinda-ORM library, which usage often implies to request data within specific ranges: Foobar.search( attr1="foo", attr2=gt(10), attr3=between(42, 50) ) The use of "gt" or "between" methods to describe those operations feels a bit cumbersome