Understanding "help" command description syntax - explanation needed

Chris Angelico rosuav at gmail.com
Wed Nov 5 13:16:16 CET 2014

On Wed, Nov 5, 2014 at 10:00 PM, Ivan Evstegneev
<webmailgroups at gmail.com> wrote:
> range(start, stop[, step]) -> range object
> For instance, how do I need to understand that (start,stop[,step])  it’s
> just a three numbers?
> What do those brackets--> [,] mean?

The docs for range() in Python 3 do need improvement, as Mark said,
although there's a bit more info than you see there. The exact text
varies from one version to another, but underneath that first line
should be something like:

"Return a virtual sequence of numbers from start to stop by step."

That should tell you a bit more, at least.

As to the brackets, they're a common convention meaning "optional".
This is much bigger than Python, so it's not actually explained
anywhere. (I've no idea where someone would go to try to find info on
these sorts of conventions. It's a little hard to do a Google search
for symbols and their usages. But that's what mailing lists like this
are for.) You can create a range object with two arguments (start and
stop) or three (start, stop, and step). When an argument is optional,
it usually has a default, and in this case, the default step is 1 -
every integer will be included.

Don't be afraid to ask questions. There are plenty of people here who
know both Python and C (I'm one of them), and we're happy to help out.
And hey, you might find you can contribute a better piece of help text
for something, and then we can make it better for every future
wonderer :)


More information about the Python-list mailing list