why won't slicing lists raise IndexError?

MRAB python at mrabarnett.plus.com
Mon Dec 4 21:24:43 EST 2017


On 2017-12-05 01:37, Jason Maldonis wrote:
[snip]

> So I guess the conclusion (as far as I can tell) is that:  `my_string[:n]`
> is more convenient than `my_string[:min(n, len(my_string))]`, and that
> sounds okay enough to me.
> 
> If I'm being completely honest I kinda like the logical explicitness of the
> latter, but it's way less convenient. And I'm 100% sure the people who made
> this decision are incredibly smart, and I certainly trust their decision.
> Thanks everyone for the responses.
> 
The first sentence of this paragraph can be summarised as "Practicality 
beats purity". It's in the Zen.



More information about the Python-list mailing list