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

Ruud van der Ham <[email protected]>
Newsgroups gmane.comp.python.announce
Message-ID <CAB-X1xHdjw1zUu53n+_QK3Zfr6M6Hh9fQZg+6qoKC8fQtygQ5g@mail.gmail.com>
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
_______________________________________________
Python-announce-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.