On 22/05/2015 1:33 p.m., Ethan Furman wrote:
Going back to the OP:
select(c for c in Customer if sum(c.orders.price) > 1000)
which compile into and run SQL like this:
SELECT "c"."id"
FROM "Customer" "c"
LEFT JOIN "Order" "order-1" ON "c"."id" = "order-1"."customer"
GROUP BY "c"."id"
HAVING coalesce(SUM("order-1"."total_price"), 0) > 1000
That last code is /not/ Python. ;)
More importantly, it's not Python *semantics*. You can't view
it as simply a translation of the Python expression into a
different language.
I still think this is really a macro facility by a different
name. I'm not saying that's a bad thing, just pointing it out.
The main difference is that a macro would (or at least could)
be expanded at compile time, whereas this would require
processing the AST each time it's used.
--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com