Skip to main content

nbprune

typical use case is, a teacher writes a notebook, with solution(s) to a problem that students must solve
so this means 2 versions, one for the teacher(s) with the solutions, and one for the students
this tool defines annotations that the teacher can use to define the parts that will be automatically removed by the tool

keywords

here are the recognized keywords

tag meaning
prune-cell remove this cell from the output
prune-begin remove this cell and the ones below from the output
prune-end remove this cell, but resume insertion on the next cell
prune-begin-next (*) keep this cell from the output, and start pruning at the next one
prune-end-previous (*) stop pruning, and insert the current cell
prune-line (*) remove just that one line from the output
prune-line-begin (**) remove that line and the following ones
prune-line-end (**) remove that line, but the following ones will show up
prune-remove-input keep the (code) cell, but mark it to have its input removed
prune-remove-output keep the (code) cell, but mark it to have its output removed

NOTES

  • (*) because prune-begin-next and prune-end-previous appear in a cell that is visible, the whole line containing the tag is removed from the output, so it is probably best to keep these tags on a separate line
  • (**) prune-line variants of course are not relevant, and are ignored, if set in the cell's metadata tags

line format

the tool will consider a tag is present in a cell if any line in the cell contains one of the above keywords, with the beginning of the line containing only # and spaces or tabs

so for exemple

line match
prune-cell yes
# prune-cell yes
# # prune-cell yes
some code prune-cell no

cell metadata

the tags can also be set in the cell's metadata as well (except for prune-line) ; something like this

{
  "tags": [
    "prune-cell"
  ]
}

examples

so that these 2 scenarios are equivalent

cell tag preserved
1 y
2 prune-cell n
3 y
4 y
5 prune-begin-next y
6 n
7 n
8 n
9 prune-end-previous y
10 y

or


cell tag preserved
1 y
2 prune-cell n
3 y
4 y
5 y
6 prune-begin n
7 n
8 prune-end n
9 y
10 y

Release files for nbprune 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbprune 0.6.0
File Size Uploaded
nbprune-0.6.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nbprune 0.6.0
File Interpreter ABI Platform
nbprune-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 kB

Release files / nbprune-0.6.0.tar.gz

Download URL nbprune-0.6.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a29360aa6bef6de0ace2a43fb1b59768adc26157bf7ed1b2d0742c37210825e8
BLAKE2b-256 checksum
How to use checksums
cd871b3e4cb30be892808296eef1c65b993bbb484c14314330dfa5e8c435df7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / nbprune-0.6.0-py3-none-any.whl

Download URL nbprune-0.6.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf0cb09637c5ed8ee45a6164315752d252efcfdd860fca888bffa5276fe27493
BLAKE2b-256 checksum
How to use checksums
cc36f1511affe5df9f2877b835a5299b850c016cafd7fb19a3fa37e1417bca85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page