Importing an output from another function
John Salerno
johnjsal at NOSPAMgmail.com
Fri Mar 17 16:11:03 EST 2006
Byte wrote:
> Now what do I do if Func1() has multiple outputs and Func2() requires
> them all to give its own output, as follows:
You can return them as a tuple:
>>> def func1():
output1 = 'hi'
output2 = 'bye'
return (output1, output2)
>>> def func2(data):
print data
>>> func2(func1())
('hi', 'bye')
> def Func1():
> choice = ('A', 'B', 'C')
> output = random.choice(choice)
> output2 = random.choice(choice)
> return output
> return output2
Only the first return statement would run in that code.
More information about the Python-list
mailing list