On Apr 16, 7:24 pm, Joe Blow <[EMAIL PROTECTED]> wrote: > 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?
>>> a = 0 >>> a==None False >>> b = None >>> b==None True >>> type(a) <type 'int'> >>> type(b) <type 'NoneType'> -- http://mail.python.org/mailman/listinfo/python-list