Skip to main content

utils.notebook_utils

Notebook and code file utilities.

get_cells

def get_cells(filepath: Path) -> t.Iterator[tuple[Optional[str], str]]

Extract cells from a Python file or Jupyter notebook.

Parameters

filepath : Path Path to the file to extract cells from.

Yields

Iterator[tuple[Optional[str], str]] Iterator yielding (cell_id, cell_source) tuples. For Python files, cell_id will be None. For Jupyter notebooks, cell_id will be the cell's ID.