Re: another newbie question: why should you use "*args" ?
- From: Bruno Desthuilliers <bruno.42.desthuilliers@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 13:23:03 +0100
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.
dummy example:
def trace(func, *args, **kw):
print "calling %s with %s %s" % (func.__name__, str(args), kw)
try:
result = func(*args, **kw)
print "got %s" % str(result)
return result
except Exception, e:
print "raised : %s" % e
raise
.
- References:
- Prev by Date: Re: another newbie question: why should you use "*args" ?
- Next by Date: Re: Sorting a List of Lists
- Previous by thread: Re: another newbie question: why should you use "*args" ?
- Next by thread: Re: another newbie question: why should you use "*args" ?
- Index(es):
Relevant Pages
|