def expanduser(path):
if path[:<NUM_LIT:1>] != '<STR_LIT>':<EOL><INDENT>return path<EOL><DEDENT>i, n = <NUM_LIT:1>, len(path)<EOL>while i < n and path[i] not in '<STR_LIT>':<EOL><INDENT>i = i + <NUM_LIT:1><EOL><DEDENT>if '<STR_LIT>' in os.environ:<EOL><INDENT>userhome = os.environ['<STR_LIT>']<EOL><DEDENT>elif '<STR_LIT>' in os.environ:<EOL><INDENT>userhome = os.environ['<STR_LIT>']<EOL><DEDENT>elif not '<STR_LIT>' in os.environ:<EOL><INDENT>return path<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>drive = os.environ['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>drive = '<STR_LIT>'<EOL><DEDENT>userhome = join(drive, os.environ['<STR_LIT>'])<EOL><DEDENT>if i != <NUM_LIT:1>: <EOL><INDENT>userhome = join(dirname(userhome), path[<NUM_LIT:1>:i])<EOL><DEDENT>return userhome + path[i:]<EOL>
Expand ~ and ~user constructs.

    If user or $HOME is unknown, do nothing.