Perhaps try something like this? variables = ['a', 'b', 'c']
defaults = { 'a': 'c:\\programs', 'b': 'd:\\data', # etc } try: settings = dict([(v, os.environ.get(v, defaults[v])) for v in variables]) except KeyError, k: # handle missing variable print "you have a problem with %s" % k.args[0] # Now if you really must have these as independent variables globals().update(settings) -- http://mail.python.org/mailman/listinfo/python-list