parameters: (path)
return_statement: return userhome + path[i:]
docstring: Expand ~ and ~user constructions.  If user or $HOME is unknown,
      do nothing.
docstring_summary: Expand ~ and ~user constructions.  If user or $HOME is unknown,
      do nothing.
docstring_tokens: Expand ~ and ~user constructions . If user or $HOME is unknown do nothing .
function: def expanduser(path):
      """Expand ~ and ~user constructions.  If user or $HOME is unknown,
      do nothing."""
      if not path.startswith('~'):
          return path
      i = path.find('/', 1)
      if i < 0:
          i = len(path)
      if i == 1:
          if 'HOME' not in os.environ:
              import pwd
              userhome = pwd.getpwuid(os.getuid()).pw_dir
          else:
              userhome = os.environ['HOME']
      else:
          import pwd
          try:
              pwent = pwd.getpwnam(path[1:i])
          except KeyError:
              return path
          userhome = pwent.pw_dir
      userhome = userhome.rstrip('/') or userhome
      return userhome + path[i:]
function_tokens: def expanduser ( path ) : if not path . startswith ( '~' ) : return path i = path . find ( '/' , 1 ) if i < 0 : i = len ( path ) if i == 1 : if 'HOME' not in os . environ : import pwd userhome = pwd . getpwuid ( os . getuid ( ) ) . pw_dir else : userhome = os . environ [ 'HOME' ] else : import pwd try : pwent = pwd . getpwnam ( path [ 1 : i ] ) except KeyError : return path userhome = pwent . pw_dir userhome = userhome . rstrip ( '/' ) or userhome return userhome + path [ i : ]