
Sept. 6, 2009
9:45 p.m.
Steven D'Aprano <steve@...> writes:
If you're expecting "exactly one result", then surely it should be an error to receive more than one result? Rather than ask for "any" result and ignoring any unexpected extra items, I think it would be better to have a helper function that verifies you have got exactly one result.
Why do you need a helper function? Simply write: x, = db.query("SELECT blah...") and you'll get a ValueError if there isn't exactly one item in the sequence. Regards Antoine.