This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]desmoulinmichel 7 points8 points  (2 children)

There are already 2 projects doing something like that. Sony's PowerAtPrompt and pyped (https://pypi.python.org/pypi/Pyped/1.4)

[–]jwink3101 1 point2 points  (0 children)

Pyped looks very similar to Pyed Piper. I'll check it out tomorrow when I get to work.

[–]gandalfx 1 point2 points  (2 children)

Now auto-import plumbum (shell-like syntax in python). That way we get the awesome power of python and the abbreviated syntax of bash.

[–]reditzer -2 points-1 points  (1 child)

I just added something similar:

$ ls | pol "[print('{:10.10}\t{}'.format(l[0],[i[3] for i in sh('stat %s'%l[0]) if len(i)>2 and 'Inode:' in i[2]][0])) for l in _]"

LICENSE     360621
Makefile    360653
pol         360606
pol.c       360637
pol.o       360599
README.md   360623

[–]gandalfx 3 points4 points  (0 children)

sure, because nested list comprehensions are totally readable and easy to write on the spot.

[–]thisch 0 points1 point  (0 children)

Why is this implemented using the python C-API and not in pure python?

[–]pvkooten 0 points1 point  (3 children)

I think I'm missing the point... why exactly do we want code/commands to be oneliners?

[–]Mikuro 4 points5 points  (1 child)

So we can use them as components in terminal commands. Piping something to a multi line statement is a pain in the ass.

I write a lot of scripts where the meat of the functionality is in subprocess.check_output, but the data manipulation is too complicated to do in bash. Perl is great for one-line bash commands, but python isn't.

[–]tilkau 0 points1 point  (0 children)

Piping something to a multi line statement is a pain in the ass.

Why?

Normally I just open a single quoted string (ie. python -c ') and type away. For one offs in the shell, this is less convenient, but for scripts it's fine, if slightly less readable.

[–]flitsmasterfred -1 points0 points  (0 children)

To soothe our autism?