I'd love this for python as I'm not a big fan of Ruby. Does such a thing exist?
The example to sort df -h by the percent:
df -h | p 'sorted({}[1:], key=lambda x: int(x.split()[-2][:-1]))'
I saved this as ~/bin/p #!/usr/bin/env python3
import sys
single_line = sys.argv[1] == '-l'
code = ' '.join(sys.argv[2 if single_line else 1:])
if single_line:
for line in sys.stdin:
print(eval(code.format('line.strip()')))
else:
print('\n'.join(eval(code.format('sys.stdin.read().splitlines()'))))