Feature Requests item #1726707, was opened at 2007-05-28 04:51
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1726707&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: add itertools.ichain function and count.getvalue
Initial Comment:
def ichain(seq):
for s in seq:
for t in s: yield t
This is like itertools.chain except seq is lazy-evaluated element-by-element.
Obvious use cases:
# equivalent of perl's "while (<>) { ... } "
for line in ichain(all_lines_of(f) for f in list_of_filenames):
do_something_with(line)
# generate infinite sequence 1,1,1,2,2,2...
seq = ichain(repeat(i,3) for i in count(1))
Also requested: it would be nice to be able to get the current counter value
from a count() instance without incrementing it, e.g.
c = count()
...
i = c.getvalue()
This is clearly useful since repr(c) does something like that internally.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1726707&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com