title: Using pexpect and winpexpect
body: <p>I have a program that uses pexpect that needs to run on both windows and linux. pexpect and winpexpect have the same API, with the exception of the spawn method. What's the best way to support both in my code?</p>
  
  <p>I was thinking something along these lines:</p>
  
  <pre><code>import pexpect
  
  use_winpexpect = True
  
  try:
      import winpexpect
  except ImportError:
      use_winpexpect = False
  
  # Much later
  
  if use_winpexpect:
      winpexpect.winspawn()
  else:
      pexpect.spawn()
  </code></pre>
  
  <p>But I'm not sure if this would work or is a good idea.</p>