Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Python-announce] unrepl: a new module to translate REPL code fragments to proper Python code

11 views
Skip to first unread message

Ruud van der Ham

unread,
Aug 12, 2022, 1:15:34 PM8/12/22
to
In many blogs, articles, books, etc. code if often presented as REPL code
fragments, like
>>> a = 1
>>> b = 2
>>> a + b
3

If you actually want to run that code, you have to remove the >>> (and ...)
and add a print statement.

With unrepl, you can do that just by copying the above code to the
clipboard and run repl.py.
The clipboard will then be changed to
a = 1
b = 2
_ = a + b; print(_) # a + b
# 3

And you can just run this code!

Unrepl can be used as a command line tool but also a module.

Instructions to create a hotkey to execute the translation of the clipboard
under Windows are in the readme.md file.

You can find unrepl (including an extensive readme) on GitHub:
www.github.com/salabim/unrepl
or you can install it from PyPI with
pip install unrepl
0 new messages