Skip to main content

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])
"""

outputs = run_interactive(code)

Output:

[1 2 3]

You can also get the clean code (without inputs and >>>) using get_clean_code method.

from strip_interactive import get_clean_code

code = """
>>> import numpy as np
>>> print(np.array([1,2,3]))
array([1, 2, 3])
"""

inputs = get_clean_code(code)
print(inputs)

Output:

import numpy as np
print(np.array([1,2,3]))

Installation

pip install strip-interactive

Metadata

Release files for strip-interactive 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strip-interactive 0.1.5
File Size Uploaded Provenance
strip-interactive-0.1.5.tar.gz 10.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for strip-interactive 0.1.5
File Interpreter ABI Platform
strip_interactive-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / strip-interactive-0.1.5.tar.gz

Download URL strip-interactive-0.1.5.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dcd803c3c1180955d43a15cd6fc969167ba9b7c561d9c42190cfe67fde20898
BLAKE2b-256 checksum
How to use checksums
3d50b4c27512a970dc6f384df0e51f0a98986b6c3fad97e66dab5eeec8b9400b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.8.1 Linux/5.4.0-73-generic

Release files / strip_interactive-0.1.5-py3-none-any.whl

Download URL strip_interactive-0.1.5-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ffac54a3843547bac18cc8d2db5f6e030858b4bcd0de70d284b711c7eee3cf3
BLAKE2b-256 checksum
How to use checksums
c89783ecaf936f354b0f4287a2aacd115e4e8c26ab583ff7df485e65be34139d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.5 CPython/3.8.1 Linux/5.4.0-73-generic

Security for strip-interactive 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page