SerialException for python not working
12:28 20 Jul 2015
 def port_button(self):      
    
    self.ser = serial.Serial()
    self.ser.baudrate = 19200
    self.ser.port = port_id
    self.ser.timeout = 6
    self.ser
  
    self.ser.open()
    while True:
        try:
            self.ser.write(dummy)
            break
        except SerialException:
            print "error"
            break

    self.ser.close()

I am trying to write code that If I choose the wrong port for Serial Communication, it will display an error message, instead of the program shutting down.

I thought the except SerialException would fix this problem

python pyserial except