Framework for Python

Notebooks & Scripts

make_script()

Create a Python script (.py) in the scripts folder.

Usage

make_script(
    name: str,
    dir: str | Path | None = None,
    stub: str = 'default',
    *,
    overwrite: bool = False,
) -> Path

Arguments

Name Type Default Description
name required str

The file name before slugifying, such as "Load Data", which becomes load-data.py. A .py extension is added when missing.

dir str | Path | None None

The folder. Default: directories: scripts in the settings, then options: script_dir, then an existing scripts/ folder, then the project root. The folder is created when missing.

stub str 'default'

The stub to start from, such as "default". The project's stubs/script-{stub}.py is used first, then your template, then Framework's.

overwrite bool False

Replace an existing file.

Value

The path of the new file.

Raises

  • FrameworkError: When the file exists and overwrite is False, or the stub is not found.