randrange exceptional behavior
MRAB
python at mrabarnett.plus.com
Mon Oct 24 16:09:16 EDT 2011
On 24/10/2011 20:26, candide wrote:
> Where is documented the behaviour of the standard function randrange in
> the case of an empty list ? for instance randrange(42,33) ? May I rely
> on an ValueError type error?
It's the same back to at least Python 2.5, so you can probably rely on
that behaviour.
Interestingly, the documentation says:
"""This is equivalent to choice(range(start, stop, step)), but doesn’t
actually build a range object."""
but for choice(seq) it says:
"""If seq is empty, raises IndexError."""
so it's not entirely equivalent.
More information about the Python-list
mailing list