4

I am new to python.I am not having any Knowledge of Python, i came across following line of python code

os.environ.get('IS_THIS_POSSIBLE', 'FALSE') == 'TRUE'

what does os.environ.get Do? Is it accessing something particular to OS internals.

1

3 Answers 3

2

Yes, it is getting operation system's environment variables. For your code, it's returning the value of os-environment variable 'ENABLE_BONDING_ROUTER', return 'FALSE' if it does not exist.

To set an environment variable see the following post on Super User: What are PATH and other environment variables, and how can I set or use them?

Sign up to request clarification or add additional context in comments.

Comments

1

Most OS's have environment variables -- for example, the $PATH variable. Python runs within the OS, and sometimes has need of those environment variables. They can be accessed through the os.environ dict.

Comments

1

os.environ is a bunch of functions to read and write the system environment and os.environ.get() returns an environment variable. See this documnetation page for some details.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.