Saving parameters between Python applications?

Diez B. Roggisch deets at nospam.web.de
Tue Sep 18 11:09:36 EDT 2007


Stodge wrote:

> os.path.expanduser isn't an option; I need each console/window to
> maintain different values which I wouldn't get from saving to a user's
> home directory. Unless I used a different file for each console/window
> but that just gets me into the same situation I'm already in. I think
> the only option is to set environment variables using another script.
> I'm really surprised and disapponited by this.

you can't do that either. It's the principle behind environment-vars that
you can't alter the ones of your parent process.

That's the reason why environment-changes must be done by using "source":


# source my_script

where my_script contains e.g.

export FOO="bar"


If you can have your user alter his/her .bashrc, you might consider creating
a environtment-variable in there that the subsequent script invocations
refer to. Like this:

# .bashrc
export SESSION=<create some unique name using e.g. date>

Then in the python-scripts you can use SESSION as a common prefix
into /tmp-residual files or such thing.

Diez



More information about the Python-list mailing list