binding more than one attribute in a facntion

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Jul 26 15:51:06 EDT 2006


linuxnow at gmail.com:
> def f(a, b, c): return a + b + c
> I can do:
> fplus10 = f(10)
> and then call f with 2 params and it works.

If you call that f or that fplus10 with two parameters you obtain an
error in both cases. You have an error with the f(10) line too.

With Python 2.5 you can probably use the partial(), but for now you can
simply do:

def f(a, b, c):
    return a + b + c
def fplus10(b, c):
    return f(10, b, c)
def fplus10plus20(c):
    return fplus10(20, c)

print f(10, 20, 30)
print fplus10(20, 30)
print fplus10plus20(30)

Bye,
bearophile




More information about the Python-list mailing list