def expandpath(path):
 path = os.path.expandvars(path)
 if path.startswith(u'~'):
  path = os.path.expanduser(path)
 return path

def expandpath ( path ) : path = os . path . expandvars ( path ) if path . startswith ( u'~' ) : path = os . path . expanduser ( path ) return path
expand ~user/ and environment $variables .