Python 3.0 - is this true?

rurpy at yahoo.com rurpy at yahoo.com
Mon Nov 10 14:21:18 EST 2008


On Nov 10, 8:57 am, Steve Holden <st... at holdenweb.com> wrote:
> Robin Becker wrote:
...snip...
>> In old style python there was a sort of standard behaviour whereby None
>> was comparable with most of the other primitive types. That at least
>> allowed us to performs various stupid tricks with data. Unfortunately it
>> seems that None is no longer orderable even against itself.
>>
>> Is there any advice on how to create N/A float or integer or string
>> values? I assume the DB api will continue to return None for null
>> columns no matter what the column type.
>>
>> Presumably I can always define my own comparator which makes None < x
>> for all x!=None.
>
> Yes, you can (though that will mean subtyping the standard Python types
> and ensuring you use only the subtypes, not always easy to maintain).
>
> Of course, using SQL against a traditional RDBMS will not return rows
> with NULL values for salary in a query such as
>
>   SELECT name, address WHERE salary < 10000
>
> precisely *because* NULL (absence of value) does not compare with any
> value.

Huh?  Thats like saying it's ok if cmp raises an error
when comparing negative numbers because "abs(x)" always
return positive ones.  You will find plenty of cases
when db apps return NULL, e.g.:

  SELECT name, salary WHERE name LIKE 'Steven %'

So you could say that 3.0 is forcing us to acknowledge database
> reality ;-)

(Again) huh?
Reality in databases is that NULL *is* comparable.
"NULL==something" returns False, it doesn't raise an error.



More information about the Python-list mailing list