Re: Extended slicing and Ellipsis - where are they used?

2007-09-15 Thread Paddy
On Sep 15, 12:29 am, James Stroud [EMAIL PROTECTED] wrote: Paddy wrote: And the ellipses ... ? ;) py class Bob(dict): ... def __getitem__(self, k, *args, **kwargs): ... if k is Ellipsis: ... return sorted(self.keys()) ... else: ... return dict.__getitem__(self, k,

Re: Extended slicing and Ellipsis - where are they used?

2007-09-15 Thread Rodney Maxwell
On Sep 13, 5:50 pm, James Stroud [EMAIL PROTECTED] wrote: Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File

Re: Extended slicing and Ellipsis - where are they used?

2007-09-15 Thread Rodney Maxwell
On Sep 13, 5:50 pm, James Stroud [EMAIL PROTECTED] wrote: Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File

Re: Extended slicing and Ellipsis - where are they used?

2007-09-14 Thread Paddy
On Sep 14, 1:50 am, James Stroud [EMAIL PROTECTED] wrote: Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File

Re: Extended slicing and Ellipsis - where are they used?

2007-09-14 Thread James Stroud
Paddy wrote: And the ellipses ... ? ;) py class Bob(dict): ... def __getitem__(self, k, *args, **kwargs): ... if k is Ellipsis: ... return sorted(self.keys()) ... else: ... return dict.__getitem__(self, k, *args, **kwargs) ... def __setitem__(self, k, *args, **kwargs):

Extended slicing and Ellipsis - where are they used?

2007-09-13 Thread Rodney Maxwell
The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers l[...] Traceback (most recent

Re: Extended slicing and Ellipsis - where are they used?

2007-09-13 Thread Robert Kern
Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers

Re: Extended slicing and Ellipsis - where are they used?

2007-09-13 Thread James Stroud
Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers