On 2006-07-23, Paul Boddie <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> >> Except that if you write your own class from scratch, you can't use >> it as a slice. > > Correct, but we were actually discussing subclassing built-in classes > for use as a replacement for range/xrange. :-)
I think a slice could be very usefull for that. To me it feel very natural that a slice would be iterable and could be used in a form like: for i in slice(10,20): or if the slice notation would be usable for i in (10:20): And why not make a slice indexable too? Whether slices really are the tool to use here or not I don know for sure. But the problem is, that you can't easily experiment with this idea because slices are not subclassable. > It may be "hard work" writing all those methods in a totally new > range/xrange class, but passing objects of that class around should > prove satisfactory for the use of most programs. But the parameters you will have to give such a class are the same you have to pass to a slice. IMO that means that you should at least consider giving slices this functionality. At least it should be easy to convert from one to the other and back. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list