title: From Python, start a shell that can interpret functions and aliases
body: <p>I have written a little *nix utility that 'reruns' a given command every time it detects filesystem changes. So I pass it the command to run as a quoted parameter, e.g.</p>
  
  <pre><code>rerun "my command"
  </code></pre>
  
  <p>Rerun is written in Python, and ends up calling:</p>
  
  <pre><code>subprocess.call("my command", shell=True, executable=USERS_DEFAULT_SHELL)
  </code></pre>
  
  <p>Where my default shell is '/bin/bash' in my case. However, the shell that subprocess.call invokes is not an 'interactive' shell, and so does not recognise the shell functions and aliases defined in my .bashrc.</p>
  
  <p>Man bash tells me that to start an interactive shell, I pass '-i' to /bin/bash. But, predictably,</p>
  
  <pre><code>subprocess.call(..., executable='/bin/bash -i')
  </code></pre>
  
  <p>doesn't work - it fails to find an executable of that name. (And even if it did work, I'm trying to make this function for whatever shell is the user's default, not just Bash. Probably '-i' doesn't do the same for all other shells.)</p>
  
  <p>How can I, from Python, execute "my command" exactly as it would have been interpreted had the user typed it into a terminal?</p>