Saving parameters between Python applications?

David wizzardx at gmail.com
Thu Sep 20 15:17:09 EDT 2007


On 9/16/07, Stodge <stodge at gmail.com> wrote:
> I'm trying to do the following. I have a Python application that is
> run:
>
> python app1.py --location=c:\test1
>
> What I want to do is save the location parameter, so I can then do (in
> the same window):
>
> python app2.py
>
> And have app2.py automatically have access to the value of "location".
>
> Now, the difficult part is, that in another window I want to do:
>
> python app1.py --location=c:\test2
> python app2.py
>
> And have app2.py automatically get c:\test2 as the location. So the
> two windows (consoles) are isolated from each other.
>
> I thought I could use os.environ, but that doesn't save the variable
> for applications that are run afterwards in the same window.

Use a value based on your current tty. I don't know how to get this
value in Python but you could just shell 'tty' and grab the output.

Or, to get your parent process's pid, use os.getppid().

Then, use a temporary file whose name is based on the above info.



More information about the Python-list mailing list