Ian Kelly wrote:

>>assert metrics
> 
> metrics is always going to be an itertools.chain object at this
> assert, so how could the assertion ever fail?

Should an assertion ever fail? 

>From your reaction I conclude that it was puzzling and a comment like

# always true in a boolean context

would have been the better choice. 


The problem I was half-heartedly addressing is that

>>>      if not metrics:
>>>         return None

"works" for empty lists but not for "empty" iterators. If it were my code 
I'd probably allow the average calculation to raise an exception and the sum 
to return 0, but there's always a limit to changing other people's code.


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

Reply via email to