parameters: (path)
return_statement: return userhome + path[i:]
docstring: Expand ~ and ~user constructs.
  
      If user or $HOME is unknown, do nothing.
docstring_summary: Expand ~ and ~user constructs.
docstring_tokens: Expand ~ and ~user constructs .
function: def expanduser(path):
      """Expand ~ and ~user constructs.
  
      If user or $HOME is unknown, do nothing."""
      if path[:1] != '~':
          return path
      i, n = 1, len(path)
      while i < n and path[i] not in '/\\':
          i = i + 1
  
      if 'HOME' in os.environ:
          userhome = os.environ['HOME']
      elif 'USERPROFILE' in os.environ:
          userhome = os.environ['USERPROFILE']
      elif not 'HOMEPATH' in os.environ:
          return path
      else:
          try:
              drive = os.environ['HOMEDRIVE']
          except KeyError:
              drive = ''
          userhome = join(drive, os.environ['HOMEPATH'])
  
      if i != 1: #~user
          userhome = join(dirname(userhome), path[1:i])
  
      return userhome + path[i:]
function_tokens: def expanduser ( path ) : if path [ : 1 ] != '~' : return path i , n = 1 , len ( path ) while i < n and path [ i ] not in '/\\' : i = i + 1 if 'HOME' in os . environ : userhome = os . environ [ 'HOME' ] elif 'USERPROFILE' in os . environ : userhome = os . environ [ 'USERPROFILE' ] elif not 'HOMEPATH' in os . environ : return path else : try : drive = os . environ [ 'HOMEDRIVE' ] except KeyError : drive = '' userhome = join ( drive , os . environ [ 'HOMEPATH' ] ) if i != 1 : #~user userhome = join ( dirname ( userhome ) , path [ 1 : i ] ) return userhome + path [ i : ]