Understanding "help" command description syntax - explanation needed

Ivan Evstegneev webmailgroups at gmail.com
Wed Nov 5 07:13:35 EST 2014


Firtst of all thanks for reply.

>>brackets [] means that the argument is optional.

That's what I'm talking about (asking actually), where do you know it from? 
I mean, if there are some resources, which explain all these syntax abbreviations? The general concept.


Like this one(just for example):
class bytearray([source[, encoding[, errors]]]) --- What does it mean? 
Is that  I can use it in optional way? 
Like: class bytearray(source) or class bytearray(encoding) ?
or just write down all three of them? 
In which format do I do so? 

Sincerely,

Ivan.

 




-----Original Message-----
From: Jean-Michel Pichavant [mailto:jeanmichel at sequans.com] 
Sent: Wednesday, November 5, 2014 13:55
To: Ivan Evstegneev
Cc: python-list at python.org
Subject: Re: Understanding "help" command description syntax - explanation needed

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