title: How to configure a tty in python with pySerial?
body: <p>The module <code>pySerial</code> provides an interface to communicate with a serial device. However, looking at the configuration of a serial device, for example <code>/dev/ttyS1</code>, there are MANY things to configure: </p>
  
  <pre><code>stty -F /dev/ttyS1 -a
  speed 1200 baud; rows 0; columns 0; line = 0;
  intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = &lt;undef&gt;; eol2 = &lt;undef&gt;; swtch = &lt;undef&gt;; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
  parenb -parodd cs7 -hupcl cstopb cread clocal -crtscts
  -ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
  -opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 -isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
  </code></pre>
  
  <p>I am especially interested in the parameter <code>-parodd cs7</code>. Is there a way to configure this parameter from within python, or do I have to call an external command to do this (like <code>stty -F /dev/ttyS1 ...</code>)?</p>