Is there an easier way to express this list slicing?

John Henry john106henry at hotmail.com
Thu Nov 30 21:08:16 CET 2006


John Henry wrote:

>
> Further, if splitUp is a sub-class of string, then I can do:
>
> alist, blist, clist, dlist = "ABCDEFGHIJ".slice((1,1,3,None))
>
> Now, can I override the slice operator?

Maybe like:

alist, blist, clist, dlist = newStr("ABCDEFGHIJ")[1,1,3,None]

where newStr is a sub-class of str, with a __repr__ that takes a
variable list of arguments?

(No clue how to code that yet, still pretty new to this)

Maybe they should make this a standard slicing feature....




More information about the Python-list mailing list