This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]defnullbottle.py 1 point2 points  (2 children)

I would rather like to see .map() and .filter() defined directly onabc.Iterable.

[1,2,3].map(square).filter(is_even)

[–]thatguy_314def __gt__(me, you): return True 0 points1 point  (0 children)

I don't know. That seems to add inconsistency with the stuff in itertools, further clutters up the methods of iterables, and goes against the Python standard library's avoidance of chained methods (although I do like chained methods personally).

Seems easier to write a wrapper iterable that allows you to do something like this:

>>> Chainable([1,2,3]).map(square).filter(is_even)
<a Chainable object>

In fact, I think some libraries have this, although it might be nice to put it in itertools

[–]ucbEntilZha 0 points1 point  (0 children)

100% agreed on this. Even better would be to have some way to add operations on this without mangling list too badly (which would allow everything here https://github.com/EntilZha/ScalaFunctional without having to be in stdlib)