Jae Kwon <jkwon.w...@gmail.com> added the comment: I second this feature request, and will try to get consensus in python-ideas.
Meanwhile, here's a sample workaround. >>> def gen2iterable(genfunc): ... def wrapper(*args, **kwargs): ... class _iterable(object): ... def __iter__(self): ... return genfunc(*args, **kwargs) ... return _iterable() ... return wrapper ... >>> >>> @gen2iterable ... def foo(): ... for i in range(10): ... yield i ... >>> a = foo() >>> >>> max(a) 9 >>> max(a) 9 >>> def secondmax(iterable): ... """return the second largest value in iterable""" ... m = max(iterable) ... return max(i for i in iterable if i<m) ... >>> secondmax(a) 8 ---------- nosy: +Jae _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5973> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com