[Tutor] How to perform variable assignment and

Mark Tolonen metolone+gmane at gmail.com
Sun Oct 4 00:05:36 CEST 2009


"wesley chun" <wescpy at gmail.com> wrote in message 
[snip]
> ... however, there is a tiny bug: if the $HOME
> environment variable is *not* set, you will get a KeyError exception.
> one solution is to add a default value to your get() method call so
> that it returns an object with a Boolean False value:

No KeyError.  Default on missing is to return None.

>>> help(os.environ.get)
Help on method get in module os:

get(self, key, failobj=None) method of os._Environ instance

-Mark




More information about the Tutor mailing list