Re: Importing an output from another function
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Importing an output from another function

From: James Stroud <jstroud@ucla.edu>
Date: Fri Mar 17 2006 - 23:18:00 CET

John Salerno wrote:
> James Stroud wrote:
>
>> Try this (I think its called "argument expansion", but I really don't
>> know what its called, so I can't point you to docs):
>>
>> def Func1():
>> choice = ('A', 'B', 'C')
>> output = random.choice(choice)
>> output2 = random.choice(choice)
>> return output, output2
>>
>> def Func2(*items):
>> print items
>>
>> output = Func1()
>> Func2(*output1)
>
>
> I was wondering about '*items' when I wrote my response. I left out the
> asterisk in my version and it still seems to work. Is it necessary?

Yours is better, after I wrote mine, I realized the asterisk was
unnecessary for this particular example, except that it makes Func2 more
general.

James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
Received on Sun Apr 30 15:22:56 2006