خرید بک لینک

Vote count: 0

I have a function that takes 3 kw parameters. I have some default values for x and y and I would like to call the function for different values of z using map. Where is run the following code I get the following error:

foo() got multiple values for keyword argument 'x'

def foo(x =1, y = 2, z = 3):
    print 'x:%d, y:%d, z:%d'%(x, y, z)


if __name__ == '__main__':
    f1 = functools.partial(foo, x= 0, y = -6)
    zz = range(10)
    res = map(f1, zz)

Is there a Pythonic way to solve this problem?

asked 16 secs ago

برچسب: python partial keyword arguments,python partial named arguments, نویسنده: استخدام کار تاريخ: سه شنبه 26 مرداد 1395 ساعت: 20:27

صفحه بندی