[GRASS-user] Define Global Variables and use them in a Python script

Glynn Clements glynn at gclements.plus.com
Tue Jul 6 11:11:41 EDT 2010


Kim Besson wrote:

> As soon as I arrive to the office I will give it a try. Thought that I could
> have global variables such as LC_LANGUAGES and other GRASS_GLOBAL VARIABLES.
> Is it possible to define them in Init.sh (or .bat) and be used in Python
> Scripts?

I think you're referring to environment variables. Those can be
accessed from within Python using os.getenv() or os.environ[]. 
However, the OS may impose limitations on the total space used by
environment variables, so you shouldn't use too many of these.

Also, environment variables are per-process, so you can't write a
script or program which modifies them for the session as a whole (this
is why GRASS has $GISRC).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list