code: def dict_to_env(d, pathsep=os.pathsep):
      '''
      Convert a python dict to a dict containing valid environment variable
      values.
  
      :param d: Dict to convert to an env dict
      :param pathsep: Path separator used to join lists(default os.pathsep)
      '''
  
      out_env = {}
  
      for k, v in d.iteritems():
          if isinstance(v, list):
              out_env[k] = pathsep.join(v)
          elif isinstance(v, string_types):
              out_env[k] = v
          else:
              raise TypeError('{} not a valid env var type'.format(type(v)))
  
      return out_enf dict_to_env(d, pathsep=os.pathsep):
      '''
      Convert a python dict to a dict containing valid environment variable
      values.
  
      :param d: Dict to convert to an env dict
      :param pathsep: Path separator used to join lists(default os.pathsep)
      '''
  
      out_env = {}
  
      for k, v in d.iteritems():
          if isinstance(v, list):
              out_env[k] = pathsep.join(v)
          elif isinstance(v, string_types):
              out_env[k] = v
          else:
              raise TypeError('{} not a valid env var type'.format(type(v)))
  
      return out_env
docs: Convert a python dict to a dict containing valid environment variable
      values.
  
      :param d: Dict to convert to an env dict
      :param pathsep: Path separator used to join lists(default os.pathsep)