Archives for: April 2008, 22
LINQ in Python
April 22nd, 2008Chui's counterpoint pines:
There are some interesting ideas raised in LINQ that even Python developers ought to explore and consider adopting in a future Python.
Python had all this before LINQ in Dejavu and now Geniusql, and more pythonically, to boot. Instead of:
var AnIQueryable = from Customer in db.Customers where
Customer.FirstName.StartsWith("m") select Customer;
you can write:
m_names = Customer.select(
lambda cust: cust.FirstName.startswith("m"))
and instead of:
var AverageRuns =(from Master in this.db.Masters
select Master.Runs).Average()
you can write:
avgruns = Masters.select(lambda m: avg(m.Runs))