TypeNone field detection

Joe Blow joeblow at nowhere.nohow
Thu Apr 17 02:24:20 CEST 2008


What is the best way to detect a TypeNone field in a tuple, or in a list?

I am accessing a MySQL database using the MySQLdb Python interface... this
interface returns a tuple object type in response to SQL SELECT
statements.  My understanding of the MySQLdb interface is that NULL
database values are returned as a Python 'None' object.

Because I need to create some work fields based on the contents of the
database I am doing so by copying the tuple to a list object and then
calculating these work fields as needed.  My problem is that I need to be
able to detect the Python 'None' objects and convert them to an integer
zero value field to enable my calculations to work.

I'm new to Python so I'm sure I'm overlooking something simple – but what
is the easiest way to do a logical test for the existence of a TypeNone
field?



More information about the Python-list mailing list