Strip and execute interactive Python string
Project description
Strip Interactive Python String
Have you ever come across an online tutorial that shows interactive Python code like this:
>>> import numpy as np
>>> print(np.array([1,2,3]))
array([1, 2, 3])
and wished to run only the inputs like below?
import numpy as np
print(np.array([1,2,3]))
That is when strip-interactive comes in handy.
Usage
To use strip-interactive, simply add the code you want to run to run_interactive
method.
from strip_interactive import run_interactive
code = """
>>> import numpy as np
>>> print(np.array([1,2,3]))
array([1, 2, 3])
"""
print(run_interactive(code))
Output:
[1 2 3]
Installation
pip install run-interactive
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
strip-interactive-0.1.2.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for strip_interactive-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2556931e52aaf46e28a1e64d63e6a371f872bf38e8e87cfc90cc750e08798651 |
|
MD5 | 5e2f815e750988b51ace9d7e6d4eb127 |
|
BLAKE2b-256 | f1789ff69a280d8ee3f0f900712cde06853cf43fbe6c3f1c9399b933c95af84e |