Post · 2 min read· pp. 992–993

aerosandbox.tools.python

Submodules

Functions

convert_ipynb_to_py(input_file, output_file)Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)
convert_ipynb_to_py(input_file, output_file)Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)
run_python_file(path)Executes a Python file from a path.
run_all_python_files(path[, recursive, verbose])Executes all Python files and Jupyter Notebooks in a directory.
lazy_import(name)Allows you to lazily import a module.

Package Contents

aerosandbox.tools.python.convert_ipynb_to_py(input_file, output_file) : Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

code
Tried using jupyter nbconvert, but that is SO SLOW, like 3 seconds per notebook! It’s just json parsing,
this should *not* take more than a few milliseconds - come on, Jupyter!

Parameters:
:   - **input\_file** (*pathlib.Path*) – File path
    - **output\_file** (*pathlib.Path*) – File path

Return type:
:   None

Returns: None

aerosandbox.tools.python.convert_ipynb_to_py(input_file, output_file) : Reads an input Jupyter notebook (.ipynb) and converts it to a Python file (.py)

code
Tried using jupyter nbconvert, but that is SO SLOW, like 3 seconds per notebook! It’s just json parsing,
this should *not* take more than a few milliseconds - come on, Jupyter!

Parameters:
:   - **input\_file** (*pathlib.Path*) – File path
    - **output\_file** (*pathlib.Path*) – File path

Return type:
:   None

Returns: None

aerosandbox.tools.python.run_python_file(path) : Executes a Python file from a path. :param path: File path

code
Returns: None

Parameters:
:   **path** (*pathlib.Path*) –

Return type:
:   None

aerosandbox.tools.python.run_all_python_files(path, recursive=True, verbose=True) : Executes all Python files and Jupyter Notebooks in a directory. :param path: A Path-type object (Path from built-in pathlib) representing a filepath :param recursive: Executes recursively (e.g. searches all subfolders too)

code
Returns: None

Parameters:
:   **path** (*pathlib.Path*) –

Return type:
:   None

aerosandbox.tools.python.lazy_import(name) : Allows you to lazily import a module.

code
Usage:
>>> asb = lazy\_import(“aerosandbox”) # Runs instantly
>>> asb.Airplane() # When this is called, ASB will be loaded.

Parameters:
:   **name** – The package name

Returns: The module itself, to be loaded on first use.