|
|
|
|
|
by 9oliYQjP
6306 days ago
|
|
I haven't used Python since 2004, and never became an expert. But isn't is possible to achieve most of what LINQ does in Python? I know in Ruby it's possible to call sort with a block (http://snippets.dzone.com/posts/show/2120). IMHO, that code resembles the spirit of LINQ. That's without even touching on the ActiveRecord portion of Rails which achieves a lot of what LINQ does too. There's got to be a way to do this sort of thing in Python too, even if it requires a third-party library. UPDATE: Here's a better example for Ruby syntax compared to LINQ. http://intertwingly.net/blog/2005/09/29/Ruby-1-8-vs-LINQ |
|
I don't know much Ruby, but I'd suspect that blocks can simulate Linq far better than Python can. However, the Lambda-inspired syntax is a bit cluttered when compared to the SQL-inspired syntax.
Linq is a feature about 3 things:
1) Correctness via static typing checks
2) Interoperability of various data backends (Microsoft provides backends for XML, SQL, and .NET objects)
3) Clean and beautiful code
Neither Python nor Ruby can provide #1 (at compile time, anyway). SqlAlchemy and other projects attempt #2, but I don't have enough experience with them to comment on their success. And while Python as a whole (and I presume Ruby) has lots of #3, complex data querying is not the most beautiful experience.