Importing an output from another function

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Mar 17 15:23:39 EST 2006


Generally, a name defined into a function can't be read outside of it,
so you have to return the function result explicitely:

import random

def Func1():
    choice = ('A', 'B', 'C')
    output = random.choice(choice)
    return output

def Func2(item):
    print item

output1 = Func1()
Func2(output1)


Bye,
bearophile




More information about the Python-list mailing list