Skip to content

datarootsio/nbdefs2py

Repository files navigation

logo

PyPI - Version PyPI - Python Version


A small package (only) to export functions and classes from notebooks to scripts

Table of Contents

Installation

pip install nbdefs2py

Usage

nbdefs2py can be used as a CLI tool or a Python function.

$ python -m nbdefs2py -h
usage: python -m nbfuncs [-h] [-i IGNORE] [--update] [--no-update] [--include INCLUDE [INCLUDE ...]]
                         [--exclude EXCLUDE [EXCLUDE ...]]
                         SRC DST

Extract definitions from notebooks.

positional arguments:
  SRC                   source file/path
  DST                   target file/path

optional arguments:
  -h, --help            show this help message and exit
  -i IGNORE, --ignore IGNORE
                        glob expression of files to ignore
  --update              update only existing functions
  --no-update           overwrite destination file
  --include INCLUDE [INCLUDE ...]
                        names of functions to include
  --exclude EXCLUDE [EXCLUDE ...]
                        names of functions to ignore
>>> from nbdefs2py.io import export
>>> export(source="nb.ipynb", destination="exported.py")

License

nbdefs2py is distributed under the terms of the MIT license.