3 ms·
I really like the style of this. I remember seeing LINQ years ago and wondering if something like it was possible in Python. I was disappointed when it looked l
by megaman821 14y ago
I really like the style of this. I remember seeing LINQ years ago and wondering if something like it was possible in Python. I was disappointed when it looked like it couldn't be done, but generating an AST then translating to SQL is smart.
It seems from this thread not many people appreciate the parity of:
list(o for o in Item if o.price>3)
when Item is a normal in-memory Python iterable, and:
select(o for o in Item if o.price>3)
when Item is a row in a database.
After just helping someone get started that was new to Python and Django, it was weird helping them learn list comprehensions and generators and then having to teach such a divergent form of syntax to work with the Django ORM even though the a lot of the concepts should be similar.
- d0mine 14y agoyou might mean "when Item is a table in a database" instead of "a row in a database". `o` would be the row.