Skip to main content

pidgin is a collection of IPython magics for creating computable essays.

Binder

    if __name__ == '__main__': 
        %load_ext pidgin

Markdown Mode

    %pidgin markdown 
---
With `pidgin.markdown`, code cells accept markdown.  Any indented code blocks are executed.

    foo = 42
    print(f"foo is {foo}")

> Accepting the `pidgin.markdown` convetion means the author agrees to indent all their code at least once; and sometimes more in nested lists. 

---

With pidgin.markdown, code cells accept markdown. Any indented code blocks are executed.

foo = 42
print(f"foo is {foo}")

Accepting the pidgin.markdown convetion means the author agrees to indent all their code at least once; and sometimes more in nested lists.


foo is 42

Template Mode

With templates real data can be inserted into the computational essay. An author should desire their notebook restart and run all during template mode.

    %pidgin template
Skipping the first line suppresses the markdown output.
---
In template mode, `jinja2` may be invoked to template markdown and code.  We already know that `foo` is 42, but can test that assertion with

    assert foo is {{foo}} is 42
    {% for i in range(3) %}print({{i}})
    {% endfor %}
---

In template mode, jinja2 may be invoked to template markdown and code. We already know that foo is 42, but can test that assertion with

assert foo is 42 is 42
print(0)
print(1)
print(2)

0
1
2
# Turning off magics

    %pidgin --off template markdown

Turning off magics

%pidgin --off template markdown

Yaml

Start code with ---

    %pidgin conventions
    ---
    a: 42
    assert a == 42

Graphviz

Start code with graph or digraph

!conda install -y graphviz
    graph { {Ipython Julia R}--Jupyter}
  File "<ipython-input-9-1661b3d05729>", line 1
    graph { {Ipython Julia R}--Jupyter}
          ^
SyntaxError: invalid syntax

Notebooks as source

pidgin uses notebooks as source; line numbers are retained so that the notebook source produces semi-sane tracebacks.

    from pidgin import markdown, template, conventions

The pidgin loader allows an author to import notebooks directly as source. This means all of the pidgin documents are importable.

    %%pidgin markdown template conventions
    import readme
    assert all(file.__file__.endswith('.ipynb') for file in (markdown, template, conventions))

Everything Should Compute

Convert a document into other formats; Restart, Run All, nbconvert.

%%pidgin markdown template
Use pidgin a cell magic to temporarily employ any convetions.

    if __name__ == '__main__':
        !jupyter nbconvert --to markdown readme.ipynb

Metadata

Release files for pidgin 0.0.1

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

Source distribution (sdist)

Source distribution for pidgin 0.0.1
File Size Uploaded
pidgin-0.0.1.tar.gz 10.5 kB Details

Built distribution (wheel)

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

Total release size: 28.3 kB

Release files / pidgin-0.0.1.tar.gz

Download URL pidgin-0.0.1.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7da890dfc843d41c76542063c551ab81d4de9ba8af44d7d917efb7612721a3a5
BLAKE2b-256 checksum
How to use checksums
1b95c6ac236ce3d9e3a3f174db1c161b4c7acab53baad7c2aaf129b4fe8d7b81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pidgin-0.0.1-py3-none-any.whl

Download URL pidgin-0.0.1-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcd84acaca8e13f8489d0c66b25868c144f4c102b60fb995fd20d542013b3a74
BLAKE2b-256 checksum
How to use checksums
7419ee91d430425c3fba62dbcba0cb7e9d37f61c3075e19313cb27bf7adc67f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 This release

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