How about adding slice notation to iterators/generators?

Anh Hai Trinh anh.hai.trinh at gmail.com
Mon Oct 26 12:51:11 EDT 2009


I've written something that is better than you could've imagine.

Get it here: <http://github.com/aht/stream.py>

It works with anything iterable, no need to alter anything.

  from itertools import count
  from stream import item
  c = count()
  c >> item[1:10:2]
->[1, 3, 5, 7, 9]
  c >> item[:5]
->[10, 11, 12, 13, 14]

There is a ton more you could do with that library, i.e. piping & lazy-
evaluation.



More information about the Python-list mailing list