code: def path_expand(text):
      
      result = os.path.expandvars(os.path.expanduser(text))
  
      # template = Template(text)
      # result = template.substitute(os.environ)
  
      if result.startswith("."):
          result = result.replace(".", os.getcwd(), 1)
  
      return result
docs: returns a string with expanded variable.
  
      :param text: the path to be expanded, which can include ~ and environment $ variables
      :param text: string