I'm wondering if it is possible to run another file: os.startfile('File.py') and have that file return a value to the file that called the other file.
For example, you have File1. Is it possible for File1 to call and run File2 and have File2 return a value to File1?
The Python return statement is a special statement that you can use inside a function or method to send the function's result back to the caller. A return statement consists of the return keyword followed by an optional return value. The return value of a Python function can be any Python object.
Why are you running Python scripts like that? the usual way is to import one module ("another file") in a Python script and invoke the public functions from there. That's what the module importing mechanism is for, please read the linked documentation.
As mentioned in the comments, this question has been asked before. Take a look at this answer for further help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With