4 ms·
Even better: Don’t use bash. I started using Python instead of bash. It’s way better to read and more maintainable. If I need the performance of native-Unix com
by hansdieter1337 6y ago
Even better: Don’t use bash. I started using Python instead of bash. It’s way better to read and more maintainable. If I need the performance of native-Unix commands, I can still use them using subprocess.
- drewbug 6y agobash is everywhere
- nhumrich 6y agoSo is python
- zeroimpl 6y agoBut which python?
- fredfjohnsen 6y agoNo, it's not. https://tidbits.com/2019/06/25/apple-to-deprecate-scripting-languages-in-future-versions-of-macos/ https://tidbits.com/2019/06/25/apple-to-deprecate-scripting-...
- ben509 6y agoPython is surprisingly bad at managing subprocesses, though. Read the subprocess docs closely, it's quite easy to get deadlocks if you try to compose operations the way you can in bash.
- aflag 6y agoThere are libraries that fix that: https://pypi.org/project/sh/ https://pypi.org/project/sh/ if you are in position to use external libraries.
- ChAns0n 6y agoPython is not as handy/efficient as bash when you want to utilize some existing Unix commands. And normally it’s crucial to stop bleeding fast if something bad is happened to you server/cluster
- argonauts12 6y agoI've been migrating shell scripts to python and have found the 'sh' library invaluable for pulling in pure CLI commands from the bash script and adding to the python implementation. http://amoffat.github.io/sh/ http://amoffat.github.io/sh/ It's essentially an abstraction layer above subprocess. Quick example - to use ifconfig natively in python: from sh import ifconfig print(ifconfig("wlan0"))