Python checking for None/Null values

John Machin sjmachin at lexicon.net
Fri Aug 11 07:18:49 EDT 2006


Fuzzydave wrote:
>
> HistoryRep is an array value so historyRep[0] to [7] all have values
> in them but historyRep[8] and [9] do not as the query does not always
> return a full 10 values. I am trying to check all of the historyRep
> items
> to check if they are empty/null/None (whatever the term is in python)
> and make it return an empty value or a none to the screen. I did print
> historyRep[8] out and it falls over, I am assuming if its an array and
> if the SQL query only returns 8 records instead of 10 then the last
> two array values i am checking for litterly don't exist instead of
> being
> null but i can't find a if exists style function either?

Just paste this in immediately after getting the result back from the
query; it's not necessarily the fastest way but it's effin' obvious
what it's doing :-)

while len(historyRep) < 10:
    historyRep.append(None)

Cheers,
John




More information about the Python-list mailing list