randrange exceptional behavior

C

candide

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?
 
M

MRAB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,157
Messages
2,570,879
Members
47,414
Latest member
djangoframe

Latest Threads

Top