Skip to main content

practical python one-liners

Project description

This module tries to improve Python’s usefulness as a tool for writing shell one-liners.

# show line numbers
python -m oneliner -ne "%5d: %s" % (NR, _) < input

# convert unix timestamp to something more human readable
date +%s | pyl -j ' => ' -line '_, datetime.datetime.fromtimestamp(int(_))'
# 1355256353 => 2012-12-11 22:05:53

# triple space a file
pyl -ne 'line + "\n"*2' < input

# double space only non-blank lines:
pyl -ne '_ if re.match("^$", _) else _+"\n"'
Documentation:

http://python-oneliner.readthedocs.org/en/latest/

Development:

https://github.com/gvalkov/python-oneliner

Package:

http://pypi.python.org/pypi/oneliner

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

oneliner-0.2.0.tar.gz (5.4 kB view hashes)

Uploaded Source

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