[Python-ideas] Break the dominance of boolean values in boolean context
Eric V. Smith
eric at trueblade.com
Thu Sep 15 22:18:32 CEST 2011
On 9/15/2011 2:00 AM, Nick Coghlan wrote:
> 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:
>>> 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'
The problem with this is the precedence difference between '&' and
sqlalchemy uses this approach, and my code contains many extra sets of
unnatural looking parens to deal with this issue. It's not a huge deal,
but I see newbies (and me, and oldie) leaving off the parens. It's not
an easy bug to track down.
More information about the Python-ideas