code: def parse_env(self, env=None, namespace=None):
          
          env = env or os.environ
          results = {}
          if not namespace:
              namespace = self.prog
          namespace = namespace.upper()  # pylint: disable=no-member
          for option in self._options:
              env_var = option.kwargs.get('env')
              default_env = "%s_%s" % (namespace, option.name.upper())
              if env_var and env_var in env:
                  value = env[env_var]
                  results[option.dest] = option.type(value)
              elif default_env in env:
                  value = env[default_env]
                  results[option.dest] = option.type(value)
  
          return results
docs: Parse environment variables.