3 ms·
My biggest annoyance is when I get some tooling from some other team, and they're like "oh just extend this Python script". It'll operate on local files, using
by jvanderbot 3y ago
My biggest annoyance is when I get some tooling from some other team, and they're like "oh just extend this Python script". It'll operate on local files, using shell commands, in a non-reentrant way, with only customization from commenting out code. Maybe there's some argparse but you end up writing a program using their giant args as primitives.
Guys just write small programs and chain them. The wisdom of the ancients is continuously lost.
- anonymous-panda 3y agoI would recommend the python sh module instead of writing bash for more complex code. Python’s devenv and tooling is way more mature and safer.
- hiccuphippo 3y agoPython comes with a built-in module called fileinput that makes this very easy. It checks sys.argv[1] and reads from it or from stdin if it's empty or a dash. https://docs.python.org/3/library/fileinput.html https://docs.python.org/3/library/fileinput.html
- dan_mctree 3y agoIt's just a preference thing, I loathe the small program chaining style and cannot work with it at all. Give me a python script and I'm good though. I can't for the life of me imagine why people would want to do pseudo programming through piping magic when chaining is so limited compared to actual programming
- dgfitz 3y agoChaining pipes in python is quite obnoxious.
- samatman 3y agoThis is of course a false dichotomy, there's nothing pseudo about using bash (perhaps you mean sudo?) and bash scripts orchestrate what you call 'actual' programs. I commonly write little python scripts to filter logs, which I have read from stdin. That means I can filter a log to stdout: cat logfile.log | python parse_logs.py Or filter them as they're generated: tail -f logfile.log | python parse_logs.py Or write the filtered output to a file: cat logfile.log | python parse_logs.py > filtered.log Or both: tail -f logfile.log | python parse_logs.py | tee filtered.log It would be possible, I suppose, to configure a single python script to do all those things, with flags or whatever. But who on Earth has the time for that?