Environment variables are part of operating systems and affect system operations. Python has Python-specific variables that affect how Python functions, that is, the behavior of the Python interpreter. While they are processed before command-line options, the command-line switches will override environment variables if there is a conflict.
Working with environment variables
How to do it...
- Environment variables are accessed via Python's os.environ.
- Because the environ object is a dictionary, you can specify a particular variable to view:
>>> import os
>>> print(os.environ["PATH"])
/home/cody/anaconda3/bin:/home/cody/bin:/home/cody/
.local/bin:/usr/local/sbin:/usr/local...