Skip to main content

impython is a python interpreter that accepts pipe stdin inputs and recognizes some magic commands.

Project description

I'm Python

What's impython?

impython is absolutely an interpreter for python based on the function exec. Besides, impython recognizes some magic commands.

Why impython?

If any program is intended to call python and to get its results (either in form of returning values or making changes in OS), the most convenient method is to start a process of python and pass python commands to python interpreter via pipe. However, the way python interacts with pipe is wired. Python will NOT execute any commands until you close the stdin. But once you close the stdin, NO other commands can you write into stdin any more.

By using python -m impython, now all issues are solved. Try this:

from subprocess import Popen, PIPE
with Popen(['python', '-m', 'impython'], stdin=PIPE) as f:
    f.stdin.write('print("hello world")'.encode())
    f.stdin.write('$exec'.encode())
    f.stdin.write('a = 1 / 0'.encode())
    f.stdin.write('$exec'.encode())
    f.stdin.write('$exit'.encode())

How to impython?

An easy way is

python -m pip install --upgrade pip
python -m pip install impython

A hard way is

git clone https://gitee.com/junruoyu-zheng/impython.git
cd impython
python setup.py build
python setup.py install

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

impython-0.1.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

impython-0.1.1-py3.8.egg (5.2 kB view details)

Uploaded Egg

File details

Details for the file impython-0.1.1.tar.gz.

File metadata

  • Download URL: impython-0.1.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for impython-0.1.1.tar.gz
Algorithm Hash digest
SHA256 04deeaaf3b15a7975b5ddb2e349d73c7a5084712d2440fdd91965af5b0ff2b63
MD5 66b3649cb68d17d059727eaef9130627
BLAKE2b-256 10930a89b6ff7f14a2f464a672fc5fe3d9fd48b4cfca7910c4b76617b621a85b

See more details on using hashes here.

File details

Details for the file impython-0.1.1-py3.8.egg.

File metadata

  • Download URL: impython-0.1.1-py3.8.egg
  • Upload date:
  • Size: 5.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for impython-0.1.1-py3.8.egg
Algorithm Hash digest
SHA256 da06cec30ac978132fd83d478dfde6a0db4aa0fb585dc438fb8367b07b48c2f9
MD5 89a3ef2d42d0da0ebcb703a781e8bb56
BLAKE2b-256 f4014a28788905c681e2444f419f71f0e636b50d714572a42e7ac42ecdfca6fd

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