Python: Get Environment Variable

By Xah Lee. Date:
# -*- coding: utf-8 -*-
# python

# example of getting environment variable

import os
print os.getenv("HOME", "default value if none") # /home/xah

15.1. os — Miscellaneous operating system interfaces — Python v2.7.6 documentation #os.environ