range Failure?
Peter Hansen
peter at engcorp.com
Sun Mar 10 19:34:36 EST 2002
Bengt Richter wrote:
>
> On Sun, 10 Mar 2002 11:07:18 -0500, "Colin J. Williams" <cjw at sympatico.ca> wrote:
> [...]
> >It might say:
> >
> > range([start= 0,] stop[, step= 1])
>
> Still, the two optional []'s are not valid in all combinations,
> (which is what you fix with your improved text ;-)
> so maybe it should say something like:
>
> range([start= 0,] stop) # where step defaults to 1, or
> range(start, stop [, step= 1])
Why not be very explicit, rather than fancy and confusing?
The above is an improvement over the original, but perhaps
this is better?
range(stop) # start is 0, step is 1
range(start, stop [, step=1])
Answering my own question: the first of the three is pretty bad.
The second one suffers from implying that Python can have optional
positional arguments which come before non-optional ones. The
third suffers from implying (perhaps?) that Python can have
overloaded methods.
Since range() doesn't take keyword arguments, even my second
one above could be considered a little bit confusing, if you
think that implies you can say range(1, 6, step=2) which you
cannot.
-Peter
More information about the Python-list
mailing list