Message307271
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 |
|
| Date |
User |
Action |
Args |
| 2017-11-29 23:00:53 | bugale bugale | set | recipients:
+ bugale bugale |
| 2017-11-29 23:00:53 | bugale bugale | set | messageid: <1511996453.35.0.213398074469.issue32172@psf.upfronthosting.co.za> |
| 2017-11-29 23:00:53 | bugale bugale | link | issue32172 messages |
| 2017-11-29 23:00:53 | bugale bugale | create | |
|