code: def expand_filename_pattern(pattern, base_dir):
      
      # 'join' ignores base_dir, if expandedPattern is absolute.
      # 'normpath' replaces 'A/foo/../B' with 'A/B', for pretty printing only
      pattern = os.path.normpath(os.path.join(base_dir, pattern))
  
      # expand tilde and variables
      pattern = os.path.expandvars(os.path.expanduser(pattern))
  
      # expand wildcards
      fileList = glob.glob(pattern)
  
      return fileList
docs: Expand a file name pattern containing wildcards, environment variables etc.
  
      @param pattern: The pattern string to expand.
      @param base_dir: The directory where relative paths are based on.
      @return: A list of file names (possibly empty).