another newbie question: why should you use "*args" ?
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Wed Jan 31 13:23:03 CET 2007
stef a écrit :
> why should I use *args,
> as in my ignorance,
> making use of a list (or tupple) works just as well,
> and is more flexible in it's calling.
Err... How so ?
> So the simple conclusion might be: never use "*args",
> or am I overlooking something ?
Try writing generic higher order functions without it, and let us know.
def trace(func, *args, **kw):
print "calling %s with %s %s" % (func.__name__, str(args), kw)
result = func(*args, **kw)
print "got %s" % str(result)
except Exception, e:
print "raised : %s" % e
More information about the Python-list