Pythonpy – Command-line Kung Fu with Python
1–10 of 40 posts
Re: Pythonpy – Command-line Kung Fu with Python
#2Python 2 :(
Re: Pythonpy – Command-line Kung Fu with Python
#3I 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
#4Python 2 :(
And python3 as well :). Just use `pip3 install pythonpy`.
Re: Pythonpy – Command-line Kung Fu with Python
#5This 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
#6Python 2 :(
It supports python3 too[0]
Re: Pythonpy – Command-line Kung Fu with Python
#7Neat. I'm curious why the quotes around the commands are necessary. Why "py '3 * 1.5'" instead of just "py 3 * 1.5"?
Re: Pythonpy – Command-line Kung Fu with Python
#8Neat. 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
#9I 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.
Re: Pythonpy – Command-line Kung Fu with Python
#10This is good stuff. Finally I don't need to hack together shell scripts with Python for adhoc text processing.