Saving parameters between Python applications?

Stodge stodge at gmail.com
Sat Oct 13 20:29:05 EDT 2007


os.getppid() isn't cross platform. I don't think it works on Windows.
I think I'll just create a simple shell script (BAT or Bash) for each
platform as needed.

Thanks

On Sep 20, 3:17 pm, David <wizza... at gmail.com> wrote:
> On 9/16/07, Stodge <sto... 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