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.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.1.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for strip_interactive-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f669c8c155fed3640e212a19645269479d444b5437971b5511b6322cbfd27ab |
|
MD5 | 7b8f0714910cd61cecff626879af4b57 |
|
BLAKE2b-256 | e1b72c0bcb006e6fdd212e4e8f4063ccb9051e9dc0e2b1fe957a081231676a1c |