Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-13 Thread Antoon Pardon
On Tue, Oct 12, 2010 at 01:50:47PM -0400, Terry Reedy wrote: > >That seems to be an undocumented feature. I didn't know it was possible > >to use extra parameters after key in __getitem__. > > They never get passed, and as I said above, should not have been > there in the version I posted. Sorry

Re: [Python-Dev] Inclusive Range

2010-10-12 Thread Steve Howell
On Oct 11, 1:40 am, Antoon Pardon wrote: > On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: > > On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: > > > > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > > > wrote: > > >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote:

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-12 Thread Terry Reedy
On 10/12/2010 9:52 AM, Antoon Pardon wrote: On Fri, Oct 08, 2010 at 05:05:26PM -0400, Terry Reedy wrote: But you really seem to be saying is "What if I sometimes want the end points included and sometimes do not?" Slice syntax by itself cannot handle all four cases, only one, one was chosen and

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-12 Thread Antoon Pardon
On Fri, Oct 08, 2010 at 05:05:26PM -0400, Terry Reedy wrote: > But you really seem to be saying is "What if I sometimes want the > end points included and sometimes do not?" Slice syntax by itself > cannot handle all four cases, only one, one was chosen and that was > closed-open. > > If you want

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-12 Thread Hallvard B Furuseth
Steven D'Aprano writes: > On Fri, 08 Oct 2010 22:10:35 +0200, Hallvard B Furuseth wrote: >> Jed Smith writes: >> a = [1, 2, 3, 4, 5, 6] >> a[::-1] >>> [6, 5, 4, 3, 2, 1] >> >> Nice. Is there a trick to get a "-0" index too? Other than doing 'i or >> len(L)' instead of 'i', that is. > > W

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-12 Thread Antoon Pardon
On Mon, Oct 11, 2010 at 05:35:21AM -0700, Ethan Furman wrote: > Antoon Pardon wrote: > >On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: > > > >>On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: > >> > > > >I stand by that claim. I think it was fairly obvious that what I meant >

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Ethan Furman
Antoon Pardon wrote: On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano wrote: On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: Personnaly I find it horrible that

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Antoon Pardon
On Mon, Oct 11, 2010 at 06:25:49AM -0400, Dave Angel wrote: > On 2:59 PM, Antoon Pardon wrote: > >On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: > > > >>But the point was that Antoon claimed that there is no numeric value for > >>the end position that will include L[0] in the rev

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Dave Angel
On 2:59 PM, Antoon Pardon wrote: On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: But the point was that Antoon claimed that there is no numeric value for the end position that will include L[0] in the reversed slice. My example shows that this is not correct. I stand by that

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Antoon Pardon
On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: > On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: > > > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > > wrote: > >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: > >> > >>> Personnaly I find it horrible > >>> tha

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 22:10:35 +0200, Hallvard B Furuseth wrote: > Jed Smith writes: > a = [1, 2, 3, 4, 5, 6] > a[::-1] >> [6, 5, 4, 3, 2, 1] > > Nice. Is there a trick to get a "-0" index too? Other than doing 'i or > len(L)' instead of 'i', that is. What exactly are you expecting? I do

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > wrote: >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: >> >>> Personnaly I find it horrible >>> that in the following expression: L[a:b:-1], it is impossible to give >>> a numeric

Re: [Python-Dev] Inclusive Range

2010-10-08 Thread Ian
On Oct 8, 3:05 pm, Terry Reedy wrote: > > doesn't imply that the sequence I need is easiest defined by > > using aninclusivelower limit. What if I wanted all none-empty > > strings/tuples keys in the tree? > > Use 'a' as the lower bound, it being the string that follows ''. No, that would be '\0'

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Terry Reedy
On 10/8/2010 4:21 AM, Antoon Pardon wrote: On Wed, Oct 06, 2010 at 05:28:13PM -0400, Terry Reedy wrote: Strings and tuples are not natural numbers, but do have least members ('' and ()), so the bottom end had better be closed. Why? Because otherwise one can never include the least member i

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Arnaud Delobelle
Hallvard B Furuseth writes: > Jed Smith writes: > a = [1, 2, 3, 4, 5, 6] > a[::-1] >> [6, 5, 4, 3, 2, 1] > > Nice. Is there a trick to get a "-0" index too? > Other than doing 'i or len(L)' instead of 'i', that is. > L = [1,2,3,4,5] L[2:-2], L[2:-1], L[2:-0] # not quite right

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Arnaud Delobelle
Jed Smith writes: > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano > wrote: >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: >> >>> Personnaly I find it horrible >>> that in the following expression: L[a:b:-1], it is impossible to give a >>> numeric value to b, that will include L[0]

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Hallvard B Furuseth
Jed Smith writes: a = [1, 2, 3, 4, 5, 6] a[::-1] > [6, 5, 4, 3, 2, 1] Nice. Is there a trick to get a "-0" index too? Other than doing 'i or len(L)' instead of 'i', that is. >>> L = [1,2,3,4,5] >>> L[2:-2], L[2:-1], L[2:-0] # not quite right:-) ([3], [3, 4], []) -- Hallvard -- htt

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Jed Smith
On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano wrote: > On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: > >> Personnaly I find it horrible >> that in the following expression: L[a:b:-1], it is impossible to give a >> numeric value to b, that will include L[0] into the reversed slice. > >

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Steven D'Aprano
On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote: > Personnaly I find it horrible > that in the following expression: L[a:b:-1], it is impossible to give a > numeric value to b, that will include L[0] into the reversed slice. >>> L = [1, 2, 3, 4, 5] >>> L[5:-6:-1] [5, 4, 3, 2, 1] --

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-08 Thread Antoon Pardon
On Wed, Oct 06, 2010 at 05:28:13PM -0400, Terry Reedy wrote: > On 10/6/2010 7:14 AM, Antoon Pardon wrote: > > >>That right-hand-half-open intervals (i.e. a<= i< b, equivalently [a, > >>b) ), which are what Python uses, are to be preferred. > >>(See aforelinked PDF: http://www.cs.utexas.edu/users/

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-07 Thread Terry Reedy
On 10/6/2010 7:14 AM, Antoon Pardon wrote: That right-hand-half-open intervals (i.e. a<= i< b, equivalently [a, b) ), which are what Python uses, are to be preferred. (See aforelinked PDF: http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF) This specifically discusses subsequences of 'natu

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-06 Thread Lawrence D'Oliveiro
In message , Antoon Pardon wrote: > Or what if the keys were floats or tuples and I wanted an > inclusive upper boundary? If you’re expecting computer floats to behave as mathematically exact quantities, you’re asking for trouble. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-06 Thread Antoon Pardon
On Tue, Oct 05, 2010 at 01:52:39PM -0700, Chris Rebert wrote: > On Tue, Oct 5, 2010 at 1:31 PM, Wolfgang Rohdewald > wrote: > > On Dienstag 05 Oktober 2010, MRAB wrote: > >> > About notation, even if loved right-hand-half-open > >> > intervals, I would wonder about [a,b] noting it. I guess > >> >

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-05 Thread Chris Rebert
On Tue, Oct 5, 2010 at 1:31 PM, Wolfgang Rohdewald wrote: > On Dienstag 05 Oktober 2010, MRAB wrote: >> > About notation, even if loved right-hand-half-open >> > intervals, I would wonder about [a,b] noting it. I guess >> > 99.9% of programmers and novices (even purely amateur) have >> > learnt ab

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-05 Thread Wolfgang Rohdewald
On Dienstag 05 Oktober 2010, MRAB wrote: > > About notation, even if loved right-hand-half-open > > intervals, I would wonder about [a,b] noting it. I guess > > 99.9% of programmers and novices (even purely amateur) have > > learnt about intervals at school in math courses. Both > > notations I kno

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-05 Thread MRAB
On 05/10/2010 20:23, spir wrote: On Tue, 05 Oct 2010 13:45:56 +0200 Boris Borcic wrote: Nick Coghlan wrote: [...] Being able to say things like "10:00"<= x< '12:00", 10.0<= x< 12.0, "a"<= x< "n" are much clearer than trying to specify their closed range equivalents. makes one wonder a