Depending on the objectives of your project, it may be a little more appropriate. Here are some pros and cons.
- Benefits for standard python library functions
- cross platform compatibility.
- usually more efficient since no child process is created.
- generally less complex because it includes fewer modules, processes, moving parts, shell parsing, etc. (therefore easier to debug as well)
- Benefits for
local fabric- it's easier to switch between
local and run or sudo as your project changes. - more consistent with
run and sudo
I think that simple local commands, which can be easily represented using the standard library functions, should be written using the standard library as the default choice due to less complexity. In each case, I asked myself a question that is more likely: running this program fabfile.py on different operating systems or converting this command from a local to a remote command, and then the code as local calls, if the latter is more likely.
source share