i thought omitting arguments in python slice operation result into:
- start =
0 - end =
len(lst) - step =
1
that holds true if step positive, step negative, in "reverse slice" [::-1], omitting start/end results in:
- start =
len(lst)-1 - end =
none
is special case, or missing something?
the default always none; type determine how handle none of 3 values. list object passed slice(none, none, -1) object in case.
see footnote 5 operations table in sequence types documentation how python's default sequence types (including list objects) interpret these:
s[i:j:k]
5. [...] if i or j omitted ornone, become “end” values (which end depends on sign of k).
so defaults dependent on sign of step value; if negative ends reversed. [::-1] end values len(s) - 1 , -1 (absolute, not relative end), respectively, because step negative.
Comments
Post a Comment