Set an environment variable

Chris F.A. Johnson cfajohnson at
Fri Oct 21 09:55:32 CEST 2005

On 2005-10-21, Christian wrote:
> Erik Max Francis wrote:
>> Christian wrote:
>>> Can I write a .py script that calls a .sh script that executes the 
>>> export command and then calls another .py script (and how would the 
>>> first .py script look)?
>> No, the shell script that the Python program would invoke would be a 
>> different process and so commands executed in it would have no effect on 
>> the state of another.
> So executing an .sh script that calls a .py script works different when 
> executed from a command promt than when executed from a starter .py script?

    No; it's always the same: an environment variable will only be
    effective in the process in which it is set, and its children.

    When you call another program, whether it's a shell script, python
    script, or binary executable, you are starting a new process.
    Environment variables set in that process will not affect its
    parent (i.e., the process that called it).

    Chris F.A. Johnson                     <>
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress

More information about the Python-list mailing list