argument type

Rocco Moretti roccomoretti at
Tue Dec 28 16:32:23 CET 2004

"It's me" wrote:

 > No, that was just an example.   I actually have additional arguments
 > that are similar to arg2.  It's not like I can do:
 >      def abc(arg1, arg3, *arg2s, *arg3s, *arg4s)


> Now, what if arg2 is not a string but either a number or a bunch of numbers?
> Using your method, can I say something to the effect of "if arg2 is *not* an
> instance of a simple number"?

Methinks you are trying to shove a 5 bushel problem in a 2 bushel sack.

Take a deep breath. Get a cup of coffee. Read the newspaper. Come back 
in 10-15 min and re-examine the problem with a fresh mind. Do you really 
have to pass multiple, variable sized lists of varying types to the same 
function? Is there some way to break the function into simpler pieces? 
Is there some better way to organize the program as a whole so that you 
avoid the issue altogether - perhaps by defining a new class?

It's been my experience that whenever I'm confused on how I'm going to 
pass a number of parameters to a function, the function is too complex 
and needs to be simplified, either by splitting it up into simpler 
functions, or by moving functionality into object methods. In the end, 
the program not only does what I want, but is also easier to understand.

More information about the Python-list mailing list