Testing existance of variable

Aahz Maruch aahz at panix.com
Mon Oct 16 12:36:43 EDT 2000


In article <z%iG5.584$7u4.12229 at news.dircon.co.uk>,
Steve George  <python-group at rascal.remove_this_bit.org> wrote:
>
>Thanks Alex - that's just the operation I wanted. According to the Quick
>Python Book I can also use it to provide a default in case the environment
>doesn't have that variable:
>
>remote_id = os.environ.get('REMOTE_HOST') or \
>			os.environ.get('REMOTE_ADDR', 'empty')

Well, yes, but you probably want the standard default of None instead of
'empty'.
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Isn't it interesting that the same people who laugh at science fiction
listen to weather forecasts and economists?" -- Kelvin Throop III



More information about the Python-list mailing list