Live data from Hacker News

Pythonpy – Command-line Kung Fu with Python

github.com

1–10 of 40 posts

Re: Pythonpy – Command-line Kung Fu with Python

#3
I didn't think I'd need something like this but it actually seems like it could be quite useful.

I think the "killer" feature is the -x modifer to apply the scriptlet to every line of input. it seems like a nice way of sticking a quick python function into a pipe of commands for when you want that little bit more than the shell (or sed) is offering you.

Re: Pythonpy – Command-line Kung Fu with Python

#5
This is awesome...Right now I'm teaching a class that starts off with bash and doing everything from the command line, and then moving into Python...the more that I can have students do from the command-line, the easier it is to get the concept of functional programming/pipes/filters across.

Re: Pythonpy – Command-line Kung Fu with Python

#8
post #7

Neat. I'm curious why the quotes around the commands are necessary. Why "py '3 * 1.5'" instead of just "py 3 * 1.5"?

Maybe the program only parses its first argument. The asterisk would need to be escaped, in any case, to prevent the shell from expanding it.

Re: Pythonpy – Command-line Kung Fu with Python

#9
I like this, Perl has been my goto choice for scripty style commands that I run directly from the command line.

While Python has the -c option, that doesn't compete with the implicit loop capability that Perl and Ruby have with the -n and -p options.

This utility seems to give a lot of that same power to Python.

Post reply on HN