Skip to content

Instantly share code, notes, and snippets.

@calebreister
Created December 18, 2013 06:38
Show Gist options
  • Save calebreister/8018190 to your computer and use it in GitHub Desktop.
Save calebreister/8018190 to your computer and use it in GitHub Desktop.
Python script for accessing environment variables.
>>> import os
>>> os.environ.keys()
KeysView(<os._Environ object at 0x013B8C70>)
>>> list(os.environ.keys())
['TMP', 'COMPUTERNAME', 'USERDOMAIN', 'PSMODULEPATH', 'COMMONPROGRAMFILES',
...many more deleted...
'NUMBER_OF_PROCESSORS', 'PROCESSOR_LEVEL', 'USERPROFILE', 'OS', 'PUBLIC', 'QTJAVA']
>>> os.environ['TEMP']
'C:\\Users\\mark\\AppData\\Local\\Temp'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment