On 12/01/2014 03:19 PM, Ethan Furman wrote: > > Well, I've tried this out, and it's only okay. As soon as interesting things > start happening, spurious errors about > thread IDs start printing, which really messes up the user experience [...]
So here's another thought: Have a small python script that loads and runs the actual script -- here's a POC: --- 8< py_main ------------------------------ #!/usr/bin/env python import sys sys.argv.pop(0) try: execfile except NameError: def execfile(file_name, globals): with open(file_name) as fh: script = fh.read() exec(fh, globals) module = {} execfile(sys.argv[0], module) module['main']() --------------------------------------------- Put the above somewhere in your path (e.g. /usr/local/bin), make it executable, and then instead of shebanging your scripts with `/usr/local/bin/python` you can use `/usr/local/bin/py_main`, which will load and execute the script, calling script.main as its last act. -- ~Ethan~
signature.asc
Description: OpenPGP digital signature
-- https://mail.python.org/mailman/listinfo/python-list