code: def clean_path(p):
      
      p = os.path.expanduser(p)
      p = os.path.expandvars(p)
      p = os.path.abspath(p)
      return p
docs: Clean a path by expanding user and environment variables and
          ensuring absolute path.