the subprocess call is a good way to call exe's, but I don't think the return code from a subprocess call can be anything that would normally be assigned to a variable named "objects" (like in sample code in the question). The return code from a process can only be an integer value.
If you wanted an exe to return anything any more complicated than an integer return code, you'd need to use an interprocess communication approach before the exe finishes. The simplest thing would be redirecting stdout and/or stderr, which would let you get back a string from the process. On 7/5/07, Dave LeCompte (really) <[EMAIL PROTECTED]> wrote:
"Ian Mallett" <[EMAIL PROTECTED]> wrote: > I was wondering if you can get returns from an executable somehow. > Something like: > > import Objects > def main() > objects = Objects.main() > > and Objects is an .exe file. > Ian > Yep, the subprocess module makes that easy. Check out http://docs.python.org/lib/module-subprocess.html http://docs.python.org/lib/node537.html You'll be most interested in the returncode attribute. -Dave LeCompte
