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

    From Ruud van der Ham@rt.van.der.ham@gmail.com to comp.lang.python.announce on Fri Aug 12 16:05:45 2022
    From Newsgroup: comp.lang.python.announce

    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
    --- Synchronet 3.19c-Linux NewsLink 1.113