Syntax help
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Jan 26 03:40:40 EST 2011
On Wed, 26 Jan 2011 00:08:41 -0800, sl33k_ wrote:
> How to read syntax like this given in the documentation of python?
> (Newbie)
>
> defparameter ::= parameter ["=" expression]
>
> http://docs.python.org/reference/compound_stmts.html#function-
definitions
See here for an explanation:
http://docs.python.org/reference/introduction.html#notation
What you are looking at is not Python code, instead it is a formal
description of what Python syntax looks like, based on a slightly
modified BNF syntax:
http://en.wikipedia.org/wiki/Backus–Naur_Form
This tells you that a "defparameter" looks like a "parameter" followed
optionally by an equals sign and an expression.
For example, here is a line of Python code:
def function(x, y=42**3):
"x" is a defparameter made up of a parameter on it's own, while "y=42**3"
is a defparameter made up of three parts: the parameter part "y", the
equals sign, and the expression part "42**3".
--
Steven
More information about the Python-list
mailing list