change a value to NULL?

Brett Hoerner bretthoerner at gmail.com
Wed Oct 5 12:20:16 EDT 2005


I'm not sure what you mean, really, do you need an official Python
"Null" value? Try None?

In [6]: myCells = ['Mary', 'Bob', None, 'Joe']

In [7]: for cell in myCells:
   ...:     if cell:
   ...:         print cell
   ...:     else:
   ...:         print "NULL VALUE"
   ...:
Mary
Bob
NULL VALUE
Joe

--

As far as having a Null value to put into the DB, most (SQL) DB's I've
used have a specific SQL command like "INSERT INTO ROW VALUE NULL()",
kind of like the SQL DATE(), etc.  I'm really rusty on my syntax etc
right now btw so don't copy and paste that. :P




More information about the Python-list mailing list