4 ms·
Thanks for this; I am starting Python coming from C# and I kept looking for LINQ equivalents. Apparently I can stop looking, it was driving me nuts :)
by mdpopescu 11y ago
Thanks for this; I am starting Python coming from C# and I kept looking for LINQ equivalents. Apparently I can stop looking, it was driving me nuts :)
- deleted 11y ago[deleted]
- ackalker 11y agoHow about this one? mcoll - Modern API for python collections: https://github.com/nvbn/mcoll https://github.com/nvbn/mcoll
- nilliams 11y agoThat looks pretty neat, thanks! I'd only previously come across underscore.py [0] (python port of underscore.js) which looked a little unmaintained though perhaps because it's 'done'. [0] https://github.com/serkanyersen/underscore.py https://github.com/serkanyersen/underscore.py
- shill 11y agoIt's not using pipes, but you can refactor the example with this Python list comprehension. def filter_authors(authors, company): return [author['twitter_handle'] for author in authors if author['company'] == company and author['twitter_handle']] EDIT: HN code formatting seems to be broken so you may need to scroll right to see the entire comprehension. You can do other SQL-like operations with list comprehensions too. http://code.activestate.com/recipes/159974-sql-like-set-operations-with-list-comprehension-on/ http://code.activestate.com/recipes/159974-sql-like-set-oper...