In Linux When I invoke python from the shell it replicates its environment, and starts the python process. Therefore if I do something like the following:
import os os.environ["FOO"] = "A_Value"
When the python process returns, FOO, assuming it was undefined originally, will still be undefined. Is there a way for the python process (or any child process) to modify the environment of its parent process?
I know you typically solve this problem using something like
But this conflicts with other requirements I have.
Trouble installing PHP 5.3.0 with intl-support
Why does locale es_MX work but not es?
composing multiple mysql scripts
You can, however, create a new environment by creating a new interactive shell with the modified environment..
Transition from Python2.4 to Python2.6 on CentOS. Module migration problem
You have to spawn a new copy of the shell that uses the upgraded environment and has access to the existing stdin, stdout and stderr, and does its reinitialization dance..
Real time video capture?
You need to do something like use subprocess.Popen to run
Running both python 2.6 and 3.1 on the same machine
So the original shell runs Python, which runs a new shell.
Debugging on Linux for Windows Developer
Yes, you have a lot of processes running.
Allowing PHP to change file and directory ownership and permission
No it's not too bad because the original shell and Python aren't really doing anything except waiting for the subshell to finish so they can exit cleanly, also..
The best you can do is to output shell statements to stdout that you then source, or write it to a file that you source in the parent..
#!/usr/bin/env python print 'FOO="A_Value"'
#!/bin/bash eval `./child.py`