On 18-Dec-09 23:16 PM, Nobody wrote:
On Fri, 18 Dec 2009 09:49:26 -0500, Colin W. wrote:
You don't say, but seem to imply that the slice components include None.
That's how missing components are implemented at the language level:
> class foo:
= def __getitem__(self, s):
= return s
=
> x = foo()
> x[::]
slice(None, None, None)
> x[1::2]
slice(1, None, 2)
The defaults of zero, sys.maxint and one apply to built-in types, but
nothing forces user-defined types to behave this way.
Or maybe I misunderstood your point.
No, it seems that the implementation is a little different from the doc.
You are right:
*** Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32. ***
>>> a= range(10)
>>> a[2:8:2]
[2, 4, 6]
>>> a[2::2]
[2, 4, 6, 8]
>>> a[2:None:2]
[2, 4, 6, 8]
>>>
I had expected the last to be rejected, but it fits with the overall
philosophy.
Colin W
--
http://mail.python.org/mailman/listinfo/python-list