December 2000
Intermediate to advanced
816 pages
16h 57m
English
These are the standard vanilla parameters that we are all familiar with. Positional arguments must be passed in the exact order that they are defined for the functions that are called. Also, without the presence of any default arguments (see next section), the exact number of arguments passed to a function (call) must be exactly the number declared:
>>> def foo(who): # defined for only 1 argument … print 'Hello', who … >>> foo() # 0 arguments… BAD Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: not enough arguments; expected 1, got 0 >>> >>> foo('World!') # 1 argument… WORKS Hello World! >>> >>> foo('Mr.', 'World!')# 2 arguments… BAD Traceback (innermost last): File "<stdin>", line 1, in ? TypeError: ...
Read now
Unlock full access