Skip to content

Commit

Permalink
Note index and slice failures in index_to_slice
Browse files Browse the repository at this point in the history
Basically append to the note in `index_to_slice` to explain that an
index that is out of bounds results in an `IndexError`, but a `slice`
that is out of bounds will just return an empty segment.
  • Loading branch information
jakirkham committed Feb 17, 2017
1 parent c3417dc commit 6b0afd0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kenjutsu/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def index_to_slice(index):
Note:
A single index behaves differently from a length 1 ``slice``. When
applying the former one reduces that dimension; whereas, applying
the latter results in a singleton dimension being retained.
the latter results in a singleton dimension being retained. Also
if an index is out of bounds, one gets an ``IndexError``. However,
with an out of bounds ``slice`` one simply doesn't get all of the
requested range (or in this case none of the requested range).
Args:
index(int): an index to convert to a slice
Expand Down

0 comments on commit 6b0afd0

Please sign in to comment.