def expand_user(path):
 tilde_expand = False
 tilde_val = ''
 newpath = path
 if path.startswith('~'):
  tilde_expand = True
  rest = (len(path) - 1)
  newpath = os.path.expanduser(path)
  if rest:
   tilde_val = newpath[:(- rest)]
  else:
   tilde_val = newpath
 return (newpath, tilde_expand, tilde_val)

def expand_user ( path ) : tilde_expand = False tilde_val = '' newpath = path if path . startswith ( '~' ) : tilde_expand = True rest = ( len ( path ) - 1 ) newpath = os . path . expanduser ( path ) if rest : tilde_val = newpath [ : ( - rest ) ] else : tilde_val = newpath return ( newpath , tilde_expand , tilde_val )
expand ~-style usernames in strings .