I was extending a `list` and am wondering why slicing lists will never raise an
 IndexError, even if the `slice.stop` value if greater than the list length.

Quick example:

my_list = [1, 2, 3]
my_list[:100]  # does not raise an IndexError, but instead returns the full
list

Is there any background on why that doesn't raise an IndexError? Knowing that
might help me design my extended list class better. For my specific use case,
it would simplify my code (and prevent `if isinstance(item, slice)` checks) if
the slicing raised an IndexError in the example I gave.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to