Skip to main content

Features after forking:

  • New token recognized for code cells, defined by #%%, used in Spyder and PyCharm scientific mode.

Original source repo readme follows...


PY2NB: Python To Notebook Converter

This is a small utility for turning python scripts into jupyter notebooks and convert module-level multiline (triple quote) string literals into markdown cells.

Why?

I wanted a tool to create user examples that can be executed as normal python scripts so that they can be copy-and-pasted easily and can be rendered as notebook for better readability (e.g nice styling, results embedded).

Also,

  • Notebooks are nice to look at but slow to write
  • Notebooks does not play well with version control

Install

python setup.py install

Usage

To convert a python script into a notebook:

python -m py2nb input.py output.ipynb

Additional commandline not from this package

Execute a notebook:

ipython nbconvert --to=notebook --execute input.ipynb

Convert a notebook to a HTML:

ipython nbconvert --to=html input.ipynb

Samples

See "samples" directory.

How?

Uses python tokenize (builtin tokenizer library) for tokenization. String literals with triple quote at column zero are converted into a comment token with special <markdowncell> and <codecell> to feed into the python importer in IPython version 3. The processed tokens are untokenized using the tokenize module so that untouched line looks exactly the same as the input.

Metadata

Release files for py2jnb 0.0.5

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

Source distribution (sdist)

Source distribution for py2jnb 0.0.5
File Size Uploaded
py2jnb-0.0.5.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py2jnb 0.0.5
File Interpreter ABI Platform
py2jnb-0.0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 13.9 kB

Release files / py2jnb-0.0.5.tar.gz

Download URL py2jnb-0.0.5.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2abcaa37cd165dd6de8ac39480462e980cdde15f2ceb011646509f6c1dea5d9b
BLAKE2b-256 checksum
How to use checksums
40a646b24ab7d20dd52b37d6123964f4fd32b223f24479456b86c94fedfe8d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Release files / py2jnb-0.0.5-py2.py3-none-any.whl

Download URL py2jnb-0.0.5-py2.py3-none-any.whl
Size 9.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f00da358ce70ab783f86a63a0de2a689df4d05166f6c075fe028f347c884f740
BLAKE2b-256 checksum
How to use checksums
63dbfb155b0ee2ed4bf127142add59a8833baa9c72df94915f9e2fe7cfb6b04f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

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