PDA

View Full Version : method with additional arguments


UnrealEd
09-08-06, 09:21 AM
hi,

i'mhaving a small problem atm: i've got a function with additional input:
def myfunc(self, *args):
print args
now my problem is this: i would like to pass these viabels into a function with an exact number of arguments. something like this:
def myfunc(*args):
print args
anotherfunc(args) # the arguments must be passed on to "anotherfunc", who requires 2 arguments:

def anotherfunc(a, b):
print a,b

# to use it:
myfunc(5, 6)
this will output "5,6", but i don't know how to pass those vars on to "anotherfunc"

i need this for an eventListener, where i have funcs who require like 4 arguments and others require no arguments

thanx in advance. i hope i clearly described my problem
UnrealEd

UnrealEd
09-08-06, 01:09 PM
srry for double posting, but i found the solution:
i had to use apply:
class Test:
def test1(self, *args):
print args
apply(self.test2, args)

def test2(self, a, b):
print a
print b
a = Test()
a.test1(1,2)

thanx anyway for anyone who has been looking
UnrealEd