Multiple arguments: how do you handle them 'nicely'?
b.hall at irl.cri.nz
Fri Aug 9 06:48:25 CEST 2002
I would be interested to know how others would tackle the following
I would like to define a function that will accept an arbitrary number
of arguments. So,
for example, I write:
for i in args:
Now for a sequence of discrete arguments like:
But for a list or tuple (which might be the result of another function's
>>> f( [1,2,3] )
>>> f( (1,2,3) )
I would prefer that f() behave the same way for either a list or tuple,
or a comma separated
series of arguments. Moreover, if f() is passed something that emulates
a sequence type then
it should handle that too.
How should I write f() so that it recognizes when it has been passed a
that is sequence-like and when it simply has a series of arguments?
More information about the Python-list