3 ms·
Python is fantastic for little (or large!) bits of logic, but its handling of input is clunky enough to put me off for tiny things. AFAIK the boilerplate you ne
by twic 8y ago
Python is fantastic for little (or large!) bits of logic, but its handling of input is clunky enough to put me off for tiny things. AFAIK the boilerplate you need to get to working on the fields on each line is:
import sys
for line in sys.stdin:
fields = line.split()
# now you can do your logic
If you want to use regular expressions, that's another import.
Python also doesn't play well with others in a pipeline. You can use python -c, but you can't use newlines inside the argument (AFAICT), so you're very limited in what you can do.
- ryl00 8y agoThis is exactly where perl (namely, perl -ne) is so very, very useful.
- usefulcat 8y agoTotally agree. On a related note, I came across a similar thing just the other day for rubyists: https://github.com/thisredone/rb https://github.com/thisredone/rb Probably not as fast as many of the individual unix tools it could replace, but does look like a great way to leverage one's knowledge of ruby.
- twic 8y agoYes, that helps a lot. The fact that Perl uses braces rather than whitespaces also makes it work much better in this situation. I still wouldn't touch Perl with a bargepole, though. Sorry not sorry.