unsetenv(key) del self.data[key] def clear(self): for key in self.data.keys(): unsetenv(key) del self.data[key] def pop(self, key, *args): unsetenv(key) return self.data.pop(key, *args) def copy(self): return dict(self) environ = _Environ(environ) def getenv(key, default=None): """Get an environment variable, return None if it doesn't exist. The optional second argument can specify an alternate default.""" return environ.get(key, default) __all__.append("getenv") def _exists(name): return name in globals()
self[k] = dict[k] if kwargs: self.update(kwargs) try: unsetenv except NameError: pass else: def __delitem__(self, key): unsetenv(key) del self.data[key] def copy(self): return dict(self) environ = _Environ(environ) def getenv(key, default=None): """Get an environment variable, return None if it doesn't exist. The optional second argument can specify an alternate default.""" return environ.get(key, default) __all__.append("getenv") def _exists(name): try: eval(name) return True except NameError: return False # Supply spawn*() (probably only for Unix)
r"""OS routines for Mac, DOS, NT, or Posix depending on what system we're on. This exports: - all functions from posix, nt, dos, os2, mac, or ce, e.g. unlink, stat, etc. - os.path is one of the modules posixpath, ntpath, macpath, or dospath - os.name is 'posix', 'nt', 'dos', 'os2', 'mac', 'ce' or 'riscos' - os.curdir is a string representing the current directory ('.' or ':') - os.pardir is a string representing the parent directory ('..' or '::') - os.sep is the (or a most common) pathname separator ('/' or ':' or '\\') - os.extsep is the extension separator ('.' or '/') - os.altsep is the alternate pathname separator (None or '/') - os.pathsep is the component separator used in $PATH etc - os.linesep is the line separator in text files ('\r' or '\n' or '\r\n') - os.defpath is the default search path for executables Programs that import and use 'os' stand a better chance of being portable between different platforms. Of course, they must then only use functions that are defined by all platforms (e.g., unlink and opendir), and leave all pathname manipulation to os.path (e.g., split and join). """ #' import sys _names = sys.builtin_module_names altsep = None __all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep", "defpath", "name"] def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']