[DB-SIG] Optional DB API Extensions
Wed, 24 Oct 2001 12:36:21 +0200
> > and if it cannot determine the value it should return -1
> > (this simplifies checking and is more in sync with the other=
At 11:04 2001-10-24 +0200, Federico Di Gregorio wrote:
>i don't think it should return a numeric value. -1 _can_ be a valid
>rowid on some dbs. None is better, imho.
I also dislike "-1". Using special values of the normal set of
return values is a bad idea. I remember the beginning of January
1999. The PBX's at Swedish hospitals didn't work. I couldn't
rent a car because the "system" was down and so on. Year = 99
must mean ERROR, right? I could well imagine that someone who
is used to the Python way of handling lists would assume that
-1 meant the last object. I could even imagine that someone
will eventually make some kind of wrapper so that the rowids
can be used like list indices etc.
After all these years I still make mistakes with string.find()...
I'm not suggesting that string.find should raise an exception
or return None if nothing is found. After all, not finding a
character in a string is something normal, hardly exceptional,
and both 0 and None are "false", so returning None would be
an invitation to bugs. But I still think the "-1" is a wart.
Is it a terrible thing to raise an exception here? After all,
if I request a value from a module that doesn't know how to
supply that, I think that is a candidate for an exception. Or
did I misunderstand something?
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel 070-582 80 65, fax: 070-612 80 65