title: Read latest character sent from Arduino in Python
body: <p>I'm a beginner in both Arduino and Python, and I have an idea but I can't get it to work. Basically, when in Arduino a button is pressed, it sends "4" through the serial port. What I want in Python is as soon as it reads a 4, it should do something. This is what I got so far:</p>
  
  <pre><code>import serial
  ser = serial.Serial('/dev/tty.usbserial-A900frF6', 9600)
  var = 1
  while var == 1:
      if ser.inWaiting() &gt; 0:
      ser.readline(1)
      print "hello"
  </code></pre>
  
  <p>But obviously this prints hello no matter what. What I would need is something like this:</p>
  
  <pre><code>import serial
  ser = serial.Serial('/dev/tty.usbserial-A900frF6', 9600)
  var = 1
  while var == 1:
      if ser.inWaiting() &gt; 0:
      ser.readline(1)
      if last.read == "4":
      print "hello"
  </code></pre>
  
  <p>But how can I define last.read?</p>