Skip to main content

Read Evaluate Print in Comments

Project description

Intro

REPIC is a Python function that will let you print output to comments inside the current file. It stands for Read, Evaluate, Print In Comments.

Install

Install Python 2.7.x and then in the terminal install via:

pip install REPIC

Usage Example

Given a file test.py with the following content:

from REPIC import REPIC
test = [1,2,3] + [4,5,6]
REPIC(test)

After running the contents of test.py become:

from REPIC import REPIC
test = [1,2,3] + [4,5,6]
REPIC(test)#OUTPUT: [1,2,3,4,5,6]

Why

Why in the world did I build this? I'm a huge fan or REPLs, but it's hard to save the output from them and go back and edit it later. iPython is great, it's probably the environment I develop Python in fastest, but with all the HTML and javascript frontend there's a lot of dependencies and new interfaces. REPIC lets you stay in your text editor or terminal environment and still get that convenient combination of code and output.

This library works great with Python 2.7 files edited with Sublime text. You run the file and the output shows up immediately. This might not be the case in every editor and Python environment since this code uses a lot of hackish features.

Thanks

iPython was a big inspiration, and its repl sessions can be saved if you prefer that kind of interface.

Thanks to users on stackoverflow for info on how to pull line numbers out of currently executing code. Thanks also to this thread discussing in-place rewrites of files in Python.

On a more philosophical level, this was inspired by Don Knuth's literate programming, REPLs, and what appears to be the first "Notebook" interface tweak to the REPL in Mathematica.

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

REPIC-1.3.tar.gz (14.9 kB view hashes)

Uploaded Source

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