Multiple Subprocess Calls Made Easy

By: Cam Wohlfeil
Published: 2018-09-13 1400 EDT
Category: Solutions
Tags: python

This is a very neat solution I figured out to calling subprocess on a bunch of commands easily with a loop.

The key here is the split(), this will break down the command in to a list, which is the format subprocess needs, without manually formatting it. I use shlex.split() here instead of the standard version based ona recommendation, because shlex can handle command line arguments with spaces.

References