code review

rusi rustompmody at gmail.com
Fri Jul 13 18:24:19 CEST 2012


On Jul 13, 8:36 pm, Chris Angelico <ros... at gmail.com> wrote:
> On Sat, Jul 14, 2012 at 1:04 AM, Steven D'Aprano
>
> <steve+comp.lang.pyt... 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

Actually a boolean algebra is a lattice with some additional
properties
A lattice is a poset (partially ordered set) with suprema and infimas
And so there is one natural order relation on any boolean algebra
which may be defined as
a ≤ b iff a ⋀ b = a

tl;dr version: In a boolean algebra, False is bottom and True is top



More information about the Python-list mailing list