title: pyserial - How to read the last line sent from a serial device
body: <p>I have an Arduino connected to my computer running a loop, sending a value over the serial port back to the computer every 100&nbsp;ms.  </p>
  
  <p>I want to make a Python script that will read from the serial port only every few seconds, so I want it to just see the last thing sent from the Arduino.</p>
  
  <p>How do you do this in Pyserial?</p>
  
  <p>Here's the code I tried which does't work. It reads the lines sequentially.</p>
  
  <pre><code>import serial
  import time
  
  ser = serial.Serial('com4',9600,timeout=1)
  while 1:
      time.sleep(10)
      print ser.readline() #How do I get the most recent line sent from the device?
  </code></pre>