[Python-ideas] data structures should have an .any() method

Georg Brandl g.brandl at gmx.net
Wed Sep 9 18:03:44 CEST 2009

Antoine Pitrou schrieb:
> 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?
> Simply write:
>     x, = db.query("SELECT blah...")
> and you'll get a ValueError if there isn't exactly one item in the sequence.



Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.

More information about the Python-ideas mailing list