Skip to main content

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

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

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.5.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strip_interactive-0.1.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file strip-interactive-0.1.5.tar.gz.

File metadata

  • Download URL: strip-interactive-0.1.5.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.1 Linux/5.4.0-73-generic

File hashes

Hashes for strip-interactive-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2dcd803c3c1180955d43a15cd6fc969167ba9b7c561d9c42190cfe67fde20898
MD5 fddf69dee588f02c6338d0f0bd12d620
BLAKE2b-256 3d50b4c27512a970dc6f384df0e51f0a98986b6c3fad97e66dab5eeec8b9400b

See more details on using hashes here.

File details

Details for the file strip_interactive-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: strip_interactive-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.1 Linux/5.4.0-73-generic

File hashes

Hashes for strip_interactive-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5ffac54a3843547bac18cc8d2db5f6e030858b4bcd0de70d284b711c7eee3cf3
MD5 72fb6430721570d3dca4bf7aa2b7136d
BLAKE2b-256 c89783ecaf936f354b0f4287a2aacd115e4e8c26ab583ff7df485e65be34139d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page