Ian Kelly wrote:

> On Wed, Nov 25, 2015 at 10:44 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote:
>> On Wed, Nov 25, 2015 at 3:07 AM, Peter Otten <__pete...@web.de> wrote:
>>>>     elif name in METRICS_AVG:
>>>           # writing a function that calculates the average without
>>>           # materialising the list left as an exercise ;)
>>
>>         metrics = itertools.tee(metrics)
>>         return int(sum(metrics[0]) / len(metrics[1]))
> 
> Actually, don't do that. It does effectively materialize the list,
> just not as a list.

Not just that, it will also complain

>>> a, b = itertools.tee([1,2,3])
>>> sum(a), len(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object of type 'itertools._tee' has no len()


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to