Skip to main content

Render reproducible examples of Python code for sharing.

Project description

reprexlite: Python reproducible examples for sharing

PyPI Supported Python Versions tests codecov

reprexlite is tool for rendering reproducible examples of Python code for sharing. It will execute your code and embed the outputs as comments below their associated lines. The rendered reprex can then be easily copied, pasted, and run as-is by anybody else. It is a lightweight alternative to reprexpy and is similarly meant as a port of the R package reprex.

Why reproducible examples?

If you're asking for help or reporting a bug, you are more likely to succeed in getting others to help you if you include a good reprex.

Why reprexlite?

reprexlite helps you create a self-contained reprex that can be easily copy-pasted and run. Your code runs in an isolated namespace. The reprex is formatted so that it is valid Python code with outputs as comments, unlike copying from a REPL. reprexlite is also very lightweight and has a convenient CLI, so you can easily and quickly get it up and running in a virtual environment.

Installation

reprexlite is available on PyPI:

pip install reprexlite

Development version

The development version of reprexlite is available on GitHub:

pip install https://github.com/jayqi/reprexlite.git#egg=reprexlite

Quick usage

Command-line interface

The reprexlite CLI allows you to create a reprex without entering Python. Simply invoke the command

reprex

This will take you into your system's default command-line text editor where you can type or paste your Python code. On macOS for example, this will be vi. You can set your default editor using the $EDITOR environment variable—I'm personally a fan of nano.

Once you're done, reprexlite will print out your reprex to console.

Python library

from reprexlite import reprex

code = """
arr = [1, 2, 3, 4, 5]
[x + 1 for x in arr]
"""

print(reprex(code))

Comparison to reprexpy

Compared to reprexpy, reprexlite adds:

  • A command-line interface so you can create reprexes without entering Python
  • Lighter dependencies (e.g., no dependence on IPython)

However, reprexlite does not have:

  • Direct ability to read from or write to your OS clipboard.
    • Instead, the CLI opens your default text editor which you can paste into.
  • Automatic upload of matplotlib plots to imgur.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reprexlite-0.1.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

reprexlite-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file reprexlite-0.1.0.tar.gz.

File metadata

  • Download URL: reprexlite-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

File hashes

Hashes for reprexlite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8fda158af68829dcc0a8bf1c0b6b5d36d139cd42d838f41d6f1fcc63d87a5e1d
MD5 a9303af29a91a19b9efa0b7d3a402aee
BLAKE2b-256 e75c12adb621910c3a429ed05e10d893607eceebb1256f9e306937fa7f90bcf6

See more details on using hashes here.

File details

Details for the file reprexlite-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reprexlite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

File hashes

Hashes for reprexlite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e423fb5cc7978d1b4b998cd9200e85b7c5ed59e9ce2c7e6fdf22cbad6fb22c24
MD5 64f2b50b132f0ea04f701f7f8ef7685e
BLAKE2b-256 0a89fa8d7a2e8dcc5bd419596728743b40de39c7e4a768e4894cdafff4993946

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page