variable function call

Uwe Schmitt uwe at rocksport.de
Thu Nov 8 10:49:22 EST 2001


Hi,

I'd like to write a wrapper-function which takes a function and a
variable parameter-list like this:


    def wrapper(fun, *args):

	... do some checks ...

	fun(args)

	... do some update of states ...


But if I use the function


   def sum(a,b): return a+b


and do

   wrapper(sum,1,2)

I get an errormessage "sum() takes two arguments ( 1 given) " because
sum() gets one tuple of two values instead of two seperate values.

Is there any trick to circumvent this error ??? The problem is, that
I'm not able to manipulate the calling-syntax of the functions
transmitted to the wrapper...

Yours, Uwe


-- 
Dr. Uwe Schmitt                                 Uwe.Schmitt at num.uni-sb.de
Universitaet des Saarlandes                     Angewandte Mathematik
Building 36.1 Room 4.17         PO-Box 151150   D-66041 Saarbruecken
Mobile:0177/6806587    Fax:+49(0)681/302-4435   Office:+49(0)681/302-2468



More information about the Python-list mailing list