This is an update to the posts that described my original Python to Arduino Interface. I upgraded the interface to add an option for generating exceptions on error and to return values directly from a read function.
The download includes a script named zzTestVoltage.py that illustrates the use of exceptions for error processing:
print "Throw error exception test"
testVoltage = float(my_board.analogRead(999)) * .0049
except interfaceError as err:
The other change implemented in this version is to return values from functions such as analogRead directly rather than as an attribute to the class. This is illustrated above as well.
If you would rather not throw exceptions you will need to check the value of the returnStatus attribute to ensure there has not been an error:
testVoltage = float(my_board.analogRead(5)) * .0049
if my_board.returnStatus != 0:
print "Error on analogRead = " + my_board.returnDebug