NULL vs. None and MySQLdb

Aahz Maruch aahz at
Tue Sep 19 18:05:12 CEST 2000

[BTW, if you're going to cc my e-mail account, please say so.]

In article <31575A892FF6D1118F5800600846864D5B10FB at intrepid>,
Simon Brunning  <SBrunning at> wrote:
> From:	aahz at [SMTP:aahz at]
>> None is the Python equivalent of NULL; what's wrong with None?
>None is not the same as NULL.

I didn't say it was the same, I said it was equivalent.

>None == None, but NULL <> NULL. For a numeric field, None == 0, but NULL <>
>0. NULL doesn't equal *anything* - it means not applicable, unknown, or
>suchlike. (I recommend SQL for Smarties by Joe Celko for a full discussion
>of this.)
>Python doesn't have any equivalent, AFAIK. Which is a shame - a native NULL
>would be *very* useful for DB work.

You should be using the "is" operator in Python to operate on None, just
the way you do in SQL.  Python has different semantics from SQL for the
relational operators, but you can get to equivalences fairly easily.
                      --- Aahz (Copyright 2000 by aahz at

Androgynous poly kinky vanilla queer het    <*>
Hugs and backrubs -- I break Rule 6

The best way to get information on Usenet is not to ask a question, but 
to post the wrong information.  --Aahz

More information about the Python-list mailing list