4 ms·
Should be titled "Shelling Out Sucks In Some Languages". Python gets this right with the subprocess module in stdlib, as the author points out at the very end.
by keypusher 11y ago
Should be titled "Shelling Out Sucks In Some Languages". Python gets this right with the subprocess module in stdlib, as the author points out at the very end.
- galonk 11y agoAs the author also points out, subprocess DOESN'T shell out. It starts the external process directly.
- cooper12 11y agoAnd some people might see that as a disadvantage, but personally I think it's a good thing that shelling out requires some setup (using `shlex` to parse a command string into an escaped list for example) and using a library rather than conveniently using backticks because it encourages you to try using the language's capabilities first. In addition to all the points mentioned by the author, another problem with relying on external commands is portability. Even the ubiquitous and UNIX-specified `grep` command contains extensions in OSX and GNU compatibility flags.