f(n=4) works; bug or feature?
Sean 'Shaleh' Perry
shalehperry at attbi.com
Mon Dec 24 06:00:50 CET 2001
On 24-Dec-2001 Edward C. Jones wrote:
> In Python 2.2, the following code prints a "4".
> def fun(n):
> print n
> Bug or feature?
feature. It is called a keyword argument.
def func(a, b, c):
func(b = 1, a = 8, c = 'hello')
The idea here is you can call the function with the arguments in any order as
long as you know their names. Hnady for long function calls like gui toolkits
or network code.
More information about the Python-list