Skip to content

Latest commit

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

This repository aims to provide convenience functions for common iterative tasks that are often verbose and
inconvenient. The aim is to be consice yet very readable. The task of mutating collections is just such a task in python. C# offers Linq to objects as an elegant solution, ruby offers blocks from methods such as '.each' and '.times' which seem very versatile. 'enumerable.py' provides a Linq-ish attempt to provide this functionality in a readable fashion in the form of a class (Enumerable) that wraps the collection, providing meaningful methods, as well as a factory function that encapsulates the creation of the wrapper in a syntactically elegant way. Performing mutations and selections from pre-existing data requires either loops and aggregation collections (tedious) or list comprehensions (cryptic?). Here's an example: # Tedious:
letters = string.ascii_uppercase
lower_case = [x.lower() for x in letters]
numbers = [ord(x) for x in lower_case]
even_numbers = [x for x in numbers if x % 2 == 0]
# Wouldn't this be nice? (assuming a few simple functions have been defined like 'lowercase')
even_numbers = for_each_in(string.ascii_uppercase).transform(lowercase).transform(ord).select(even)
Future features:
- accept a file name or maybe a file object in the constructor (assumes that actions would be performed as the lines in the file were iterated over).

About

A more Linq-like way to work with (almost all) Python iterables.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages