code: def open_python_file(filename):
      """Open a read-only Python file taking proper care of its encoding.
  
      In Python 3, we would like all files to be opened with utf-8 encoding.
      However, some author like to specify PEP263 headers in their source files
      with their own encodings. In that case, we should respect the author's
      encoding.
      """
      import tokenize
  
      if hasattr(tokenize, "open"):  # Added in Python 3.2
          # Open file respecting PEP263 encoding. If no encoding header is
          # found, opens as utf-8.
          return tokenize.open(filename)
      else:
          return open(filename, "r", encoding="utf-8")
  
file_path: streamlit/lib/streamlit/source_util.py
imports: import re
  import threading
  from pathlib import Path
  from typing import Any, Callable, Dict, Optional, Tuple, cast
  from blinker import Signal
  from streamlit.logger import get_logger
  from streamlit.string_util import extract_leading_emoji
  from streamlit.util import calc_md5
label_desc: Use image node_id 1 for calling a global function with example usage: open_python_file(filename) and returns: tokenize, open