code: def expand_dir(_dir, cwd=os.getcwd()):
      
      _dir = os.path.expanduser(os.path.expandvars(_dir))
      if not os.path.isabs(_dir):
          _dir = os.path.normpath(os.path.join(cwd, _dir))
      return _dir
docs: Return path with environmental variables and tilde ~ expanded.
  
      :param _dir:
      :type _dir: str
      :param cwd: current working dir (for deciphering relative _dir paths)
      :type cwd: str
      :rtype; str