[Python-ideas] data structures should have an .any() method
solipsis at pitrou.net
Sun Sep 6 23:45:49 CEST 2009
Steven D'Aprano <steve at ...> 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?
x, = db.query("SELECT blah...")
and you'll get a ValueError if there isn't exactly one item in the sequence.
More information about the Python-ideas