开发者

is there LINQ for python 3.x?

开发者 https://www.devze.com 2023-01-23 17:09 出处:网络
Does it exists ? There is http://github.com/heynemann开发者_运维问答/pynq , but only for 2.5 You could try asq which is a complete LINQ-inspired implementation for both Python 2 (2.6 and 2.7) and Pyth

Does it exists ? There is http://github.com/heynemann开发者_运维问答/pynq , but only for 2.5


You could try asq which is a complete LINQ-inspired implementation for both Python 2 (2.6 and 2.7) and Python 3 (all versions). Queries in asq can be performed over any Python iterable and feature deferred evaluation just like LINQ. The implementation is pretty solid with 100% test coverage and comprehensive documentation. The API is PEP8 compliant so it fits nicely with other Python code and some other goodies are provided to improve integration with Python. Finally, version 1.0 contains prototype support for parallel query execution.

Full disclosure: I am the author of asq.


As SilentGhost suggests, running 2to3 reveals that there are minimal changes to make to port to python 3.x. Broadly, they are:

  1. Change calls to unicode() to str()
  2. Remove 'u' on unicode string constants
  3. Change dict.has_key() to dict.in
  4. Change cStringIO import to io
  5. Change StringIO.next to StringIO.__next__

I'd quote it all for you, but the output will not play nice with StackOverflow formatter.


There's an official Microsoft wip Rx implementation for Python called Rx.py. It includes a basic implementation of LINQ-to-objects (IEnumerable), which you can see here: http://rxpy.codeplex.com/SourceControl/latest#rx/internal/enumerable.py.

This project targets Python 3.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号