Main Content

Python - what is going on around me?

Archive - Originally posted on "The Horse's Mouth" - 2010-02-28 04:57:25 - Graham Ellis

If you want to find out what's going on around you in a Python program, you can uses your system's environment variables via the os.environ module - the keys() method telling you which environment variables are available to you. There's an example [here] from our Python Programming training course.

Python is also effected in how it runs by a number of specific environment variables, allowing you to control where it looks to load modules and how deeply it optimise's the compiled code, for example. There's a list of all of those (except the series provided for debugging of the Python language itself) at the end of the example above.