Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Steven D'Aprano
On Sat, Nov 10, 2018 at 10:58:02PM -0700, Nicholas Harrison wrote: [...] > (start:stop:step) > > > Meet a range/slice object. Parentheses are required. (Its syntax in this > regard follows exactly the same rules as a generator expression.) I say > both range and slice because it can be used in e

Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Robert Vanden Eynde
I'm wondering how your examples would go with from funcoperators import infix (https://pypi.org/project/funcoperators/) sum(1:6) # instead of sum(range(1, 6)) > > sum(1 /exclusive/ 6) list(1:6) > > list(1 /exclusive/ 6) set(1 /exclusive/ 1) Note that you can pick another name. Note that you can

Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Vladimir Filipović
On Sun, Nov 11, 2018 at 6:59 AM Nicholas Harrison wrote: > Any of the values may be omitted and in the slice context the behavior has no > changes from what it already does: start and stop default to the beginning or > end of the list depending on direction and the step defaults to 1. Just to

Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Juancarlo Añez
On Sun, Nov 11, 2018 at 6:00 AM Chris Angelico wrote: > Be careful of this last one. If you omit the step, it looks like this: > > {start:stop} > > which is a dictionary display. > The parenthesis could always be required for this new syntax. In [*1*]: {'a':1} Out[*1*]: {'a': 1} In [*2*]: {(

Re: [Python-ideas] Range and slice syntax

2018-11-11 Thread Steven D'Aprano
On Sun, Nov 11, 2018 at 04:34:16PM +, Juancarlo Añez wrote: > On Sun, Nov 11, 2018 at 6:00 AM Chris Angelico wrote: > > > Be careful of this last one. If you omit the step, it looks like this: > > > > {start:stop} > > > > which is a dictionary display. > > > > The parenthesis could always be