title: If-then bash statement as a sequence in Python subprocess
body: <p>Is there any way to execute the <code>if-then</code> bash statement as a sequence in Python subprocess?
  I can execute the <code>if-then</code> statement as a string, but I want to convert it into a sequence for a safer code.</p>
  
  <p>This is my program at the moment. It uses string as the first input of the subprocess with <code>shell=True</code> argument.
  </p>
  
  <pre><code># this example works
  import subprocess
  p = subprocess.Popen('if [ ! -d "dir1" ]; then mkdir dir1; fi;', shell=True)
  </code></pre>
  
  <p>I want to convert the first argument as a sequence with <code>shell=False</code> argument, but I don't know how to make the statement above as a sequence. This is what I've tried.
  </p>
  
  <pre><code># this example does not work
  import subprocess
  p = subprocess.Popen(['if','[ ! -d "dir1" ];','then','mkdir','dir1;','fi;'], shell=False)
  </code></pre>