how to use env variables in python fields?

the classic example. I have a $mygeo environment variable that contains path/name.bhclassic

in a file sop, if in hscript mode I can just use $mygeo as filename.

but in python mode… I’m not sure how that can be done. I can’t use the os.environ modules because it’s not imported by default. Any way in Touch to access environment variables easy in field expressions?

tx
d

You should be able to do it via:

var('mygeo')

d’oh!

tx!
d

No problem.

var(‘mygeo’)

This is no longer correct.

To repro, run Touch from batch file

set DEBUG=0

Save root DEBUG=1 variable

In Touch on next start, both variables appear in Variables / Macros panel correctly but default scope is root not environment (eg DEBUG=1)

How do you access env vars now? Using v99 12100

import os os.environ["DEBUG"]