December 2000
Intermediate to advanced
816 pages
16h 57m
English
Default arguments are parameters which are defined to have a default value if one is not provided in the function call for that argument. Such definitions are given in the function declaration header line. C++ and Java are other languages which support default arguments and whose declaration syntax is shared with Python: The argument name is followed by an “assignment of its default value. This assignment is merely a syntactical way of indicating that this assignment will occur if no value is passed in for that argument.
The syntax for declaring variables with default values in Python is such that all positional arguments must come before any default arguments:
def function_name(posargs, defarg1=dval1, defarg2=dval2,…): ...
Read now
Unlock full access