Skip to main content

Tiny helper for command-line python

Project description

# command line tool #

Use like this:

cat data.tsv | cut -c4,9 | py “print(‘DELETE FROM sites WHERE id IN ({0})’.format(‘,’.join(IN)))” | psql testdb admin

Where the py bit replaces the slightly longer command:

python -c “import sys; print ‘DELETE FROM sites WHERE id IN ({0})’.format(‘,’.join(sys.stdin))”

I made this because I am tired of reading man pages for awk and sed and others; I already know python, but I am also tired of typing import sys, etc repeatedly.

os, sys, csv and json are pre-imported, as well as unicode_literals and print_function from the future.

Aditionally the following are imported and renamed:

sys.stdin -> IN sys.stdout -> OUT functools -> FT itertools -> IT operator -> OP pprint.pprint -> PP


For those interested in more robust solutions checkout <a href=’https://github.com/alecthomas/pawk’>pawk</a> or <a href=’http://code.google.com/p/pyp/’>pyp</a>.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shell-pype-0.1.1.tar.gz (894 Bytes view details)

Uploaded Source

File details

Details for the file shell-pype-0.1.1.tar.gz.

File metadata

  • Download URL: shell-pype-0.1.1.tar.gz
  • Upload date:
  • Size: 894 Bytes
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for shell-pype-0.1.1.tar.gz
Algorithm Hash digest
SHA256 971c74da0c1019b1c2415cf17d2e9d8abac5ab070d2614302c1d571c6d903bc9
MD5 735c623f61a2018a488f05fa852bd279
BLAKE2b-256 d3970e0e2ce69f0bb7132b83fed45634cbc938bcc6fdb8753523ed585b1d1577

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