title: python, set terminal type in pexpect
body: <p>I have a script which uses pexpect to start a CLI program. It works a bit like a shell where you get a prompt where you can enter some commands.</p>
  
  <p>The problem I have, I think, is that this program uses a coloured prompt.</p>
  
  <p>This is what I do </p>
  
  <pre><code>import pprint
  import pexpect
  
  1 a = pexpect.spawn('program')
  2 a.expect("prompt&gt;")
  3 print "---------start------------"
  4 print(a.before)
  5 a.sendline("command")
  6 a.expect("prompt&gt;")
  7 print "---------before------------"
  8 pprint.pprint(a.before)
  9 print "---------after------------"
  10 pprint.pprint(a.after)
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>&gt; python borken.py
  ---------start------------
  A lot of text here from the enjoying programs start-up, lorem ipsum ...  
  ---------before------------
  ' \x1b[0m\x1b[8D\x1b[K\x1b[1m\x1b[34m'
  ---------after------------
  'prompt&gt;'
  </code></pre>
  
  <p>For some reason the first prompt colour coding borkens up things and a.before at line 8 is garbled, normal print does not work,  even if I see that the command at line 5 actually produced a lot of output.</p>
  
  <p>Does someone know what the problem could be, or is it possible to set the terminal type in pexpect to avoid the colours?</p>
  
  <p>I am using tcsh shell</p>