Difference between os.getenv and os.environ.get?

Is there any difference at all between these two? When should I use one over the other? Is one of these deprecated? They seem to have the exact same functionality.

    >>> os.getenv('TERM')
    >>> os.environ.get('TERM')

    >>> os.getenv('FOOBAR', "not found") == "not found"
    >>> os.environ.get('FOOBAR', "not found") == "not found"

One difference observed (Python27):

os.environ raises an exception if the environmental variable does not exist. os.getenv does not raise an exception, but returns None

From: stackoverflow.com/q/16924471

Back to homepage or read more recommendations: