[Python-ideas] Break the dominance of boolean values in boolean context

Nick Coghlan ncoghlan at gmail.com
Thu Sep 15 08:00:09 CEST 2011

On Thu, Sep 15, 2011 at 3:30 PM, Chris Rebert <pyideas at rebertia.com> wrote:
> On Wed, Sep 14, 2011 at 9:22 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> <snip>
>> NumPy is not the only use case by a long shot. The main reason
>> I want it is for expressing database queries. You only have to
>> look at the contortions that things like Django have to go
>> through to wonder whether there's a better way.
> So, you want this in order to avoid (e.g.) `X & Y` and `not_(Z)`, in
> favor of `X and Y` and `not Z`? Doesn't seem like that big of a win in
> the `and` and `or` cases.

It's actually:

'x and y' vs 'x & y'
'x or y' vs 'x ^ y'
'not x' vs '~x'

(assuming you aren't already using the bitwise versions for bitwise operations)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list