Understanding "help" command description syntax - explanation needed

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Nov 5 12:55:00 CET 2014


---- Original Message -----
> From: "Ivan Evstegneev" <webmailgroups at gmail.com>
> To: python-list at python.org
> Sent: Wednesday, 5 November, 2014 12:00:16 PM
> Subject: Understanding "help" command description syntax - explanation needed
> So here is the question itself:
> 
> If I use the help command to check the “range” command I get this
> info:
> 
> 
> 
> range(stop) -> range object
> 
> range(start, stop[, step]) -> range object

With python 2.7, when I type help(range), I get

"""
Help on built-in function range in module __builtin__:

range(...)
    range([start,] stop[, step]) -> list of integers
    
    Return a list containing an arithmetic progression of integers.
    range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
    When step is given, it specifies the increment (or decrement).
    For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!
    These are exactly the valid indices for a list of 4 elements.
"""

range([start,] stop[, step]) tells you how to call the range function, there's a start, stop and step argument.
The purpose of these arguments are given by the longer description.

brackets [] means that the argument is optional.

Though there's nothing wrong with googling the function for help, I'm doing it all the time.
Actually, the python documentation is a better place to get help on a particular function, just make sure you hit the correct version, for either python 2 or 3:

https://docs.python.org/2/library/functions.html#range

I'm using python's help function only when working offline.

JM



-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list