Thanks. Good to know another alternativebenalb wrote: ↑Thu Mar 29, 2018 2:39 pmI usually do this:
and then, can do:Code: Select all
cat test01.py def my_test(): print("hello, test") def main(): my_test() if __name__ == "__main__": main()
Code: Select all
>>> import test01 >>> from test01 import my_test >>> >>> test01.my_test() hello, test >>> test01.main() hello, test >>> >>> my_test() hello, test
how to execute "OTHER" python scripts
Re: how to execute "OTHER" python scripts
- electricidea
- Posts: 1
- Joined: Wed Mar 09, 2022 12:52 pm
- Location: Germany
- Contact:
Re: how to execute "OTHER" python scripts
Another possibility is to load and execute the script with the exec() command:
exec(open("foo.py").read())
exec(open("foo.py").read())
-
- Posts: 44
- Joined: Fri Sep 02, 2016 4:07 pm
- Location: Austria
Re: how to execute "OTHER" python scripts
Is it possible to execute another script and get the output of it in a variable?
something like:
something like:
Code: Select all
subprocess.getoutput('echo xyzzy')