Skip to main content

Evaluate and display command line expressions with python -me expr

Project description

For example:

$ python -me 1 + 1
2

Like python -c but no need for a print. But wait, there’s more.

As a bonus, if the first argument is a module name then it will output the location of the module source code:

$ python -me os
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py

If you follow the name of the module with a command then the module will be opened with that command. For example, the following will open the os module source in vim:

$ python -me os vim

The “e” module recognises the special command names “edit” and “view” which will result in it looking up your editor and viewer commands in the environment variables $EDITOR and $PAGER respectively. The latter defaults to “less”. This is slightly easier than writing, for example:

$ vim `python -me os`

… especially if you’re going back to edit a previous “python -me” command using line editing.

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

e-1.4.2.tar.gz (1.7 kB view details)

Uploaded Source

File details

Details for the file e-1.4.2.tar.gz.

File metadata

  • Download URL: e-1.4.2.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for e-1.4.2.tar.gz
Algorithm Hash digest
SHA256 d85ab2b57f9000d8fbd7bafdfcb36bc8501be7d7ff062168c53793ede839cab7
MD5 3b8a18707b96a4c9375058f444ed1d85
BLAKE2b-256 91a9dbfee760c3fee77e54df011edbdf10ff3ee026d8fcb7166be1b2de60dfbd

See more details on using hashes here.

Supported by

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