[Numpy-discussion] [help needed] associativity and precedence of '@'
Mon Mar 17 20:25:30 CDT 2014
On Mon, Mar 17, 2014 at 8:54 PM, Nathaniel Smith <email@example.com> wrote:
> Currently Python has 3 different kinds of ops: left-associative (most
> of them), right-associative (**), and "chaining". Chaining is used for
> comparison ops. Example:
> a < b < c
> gets parsed to something like
> do_comparison(args=[a, b, c], ops=[lt, lt])
The actual parse tree is more like Compare(a, [lt, lt], [b, c]) with the
first aruments playing a distinct role:
>>> ast.dump(ast.parse('a<b<c'), annotate_fields=False)
"Module([Expr(Compare(Name('a', Load()), [Lt(), Lt()], [Name('b', Load()),
Your idea is very interesting and IMO, worth considering independently from
the @ operator. I always wanted a vector "between" operator to be
available in numpy as low < x < high.
The only problem I see here is with mixed types, but we can follow the pow
precedent : "Note that ternary pow() will not try calling __rpow__()
(the coercion rules would become too complicated)."
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion