def dict_to_env(d, pathsep=os.pathsep):
out_env = {}<EOL>for k, v in d.iteritems():<EOL><INDENT>if isinstance(v, list):<EOL><INDENT>out_env[k] = pathsep.join(v)<EOL><DEDENT>elif isinstance(v, string_types):<EOL><INDENT>out_env[k] = v<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>'.format(type(v)))<EOL><DEDENT><DEDENT>return out_env<EOL>
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)