If one types a[4:8:2] in Python, Python creates a slice object (call
it s) with s.start = 4, s.stop = 8 and s.step = 2.  It then passes
this slice object to a's __getitem__ method.  If one of the arguments
is left out, it is filled with None: so the slice [:8:2] would have
start None.  However, if you don't have the second colon, instead of
filling it with None, it fills start with a Python int 0 and stop with
a Python int 2147483647 (which some of you may recognize as maxint).
So a[:4] would call __getslice__(0, 4), or if that's not defined,
__getitem__(slice(0, 4)).  Similarly, if I write a[-2:8] it calls
__getitem__(slice(a.__len__() - 2, 8, None)).  Is there any way that I
can distinguish between a[0:4] and a[:4] in writing __getitem__?   Or
more generally, get Python to construct a new style slice object when
called with just two arguments?  I want to overload the slice operator
for p-adic fields and this is stymieing me (yes, that is how you spell
stymieing: I just looked it up).
David


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to