Movatterモバイル変換


[0]ホーム

URL:


return values from scripts

Alex Martellialeaxit at yahoo.com
Tue Apr 17 15:03:20 EDT 2001


"Mike Burnett" <mnb at ornl.gov> wrote in messagenews:3ADC8257.CC51FE1B at ornl.gov...> While running a script in the python interpreter, I need to run a second> script from the first, passing some values to the second.  I know I can> do this with: execfile('second.py',locals()).  Is there any way to get> back into the original script one value (a return status) from the> second script?  Is there any way to get several parameter values back?Simplest is probably to arrange that second.py sticks his result[s]into variables in "its" dictionary and first.py fetches them backfrom there.  For the purpose I would pass a fresh dictionary:results = {}execfile('second.py', vars(), results)for name, value in results.items():    print "second.py set %s to %s" % (name, value)Alex


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp