code review

Chris Angelico rosuav at gmail.com
Fri Jul 13 11:36:47 EDT 2012


On Sat, Jul 14, 2012 at 1:04 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Actually, no. Is True less than False, or is it greater? In boolean
> algebra, the question has no answer. It is only an implementation detail
> of Python that chooses False < True.

Maybe in boolean algebra, but in code, it's handy to have sortable
bools. In SQL, for instance, I can use a boolean in an ORDER BY,
perhaps followed by another criterion, and it's effectively sorting by
"1 if some_boolean else 0" or in C notation "some_boolean ? 0 : 1"

ChrisA



More information about the Python-list mailing list