complement to $

Kagamin spam at here.lot
Mon May 17 03:23:36 PDT 2010


bearophile Wrote:

> Another example are range bounds, you can omit them, or exactly the same, they can be None:
> 
> a = ['a', 'b', 'c', 'd']
> >>> assert a[None : 2] == ['a', 'b']
> >>> assert a[ : 2] == ['a', 'b']
> >>> assert a[0 : 2] == ['a', 'b']
> >>> idx = None
> >>> assert a[idx : 2] == ['a', 'b']
> >>> assert a[2 : None] == ['c', 'd']
> >>> assert a[2 : ] == ['c', 'd']
> >>> assert a[2 : len(a)] == ['c', 'd']

half of a slice: a[None+len(a) : None]


More information about the Digitalmars-d mailing list