New submission from bugale bugale <buga...@gmail.com>: I have noticed that there is no convenient way in python to get the number of items in a generator.
For example: my_iterable = iter(range(1000)) len(my_iterable) # Would not work Of course, something like this would ruin the generator, and it will no longer be usable, but in some use cases one would like to know only the count of something. It is possible to do it today using this line: sum(1 for x in my_iterable) but it seems odd to me that there is no function like: itertools.count_iterable(my_iterable) that does exactly this ---------- components: Demos and Tools messages: 307271 nosy: bugale bugale priority: normal severity: normal status: open title: Add length counter for iterables type: enhancement versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32172> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com