New submission from Peter Norvig :
In the itertools recipes (
https://docs.python.org/3/library/itertools.html#itertools-recipes ) there are
21 functions that have single-quote docstrings. These should be changed to
triple-quotes, as mandated in PEP 257.
--
messages: 381704
nosy
New submission from Peter Norvig:
mean([True, True, True, False]) should be 0.75, but it returns 0.25.
The fix is to change _sum so that when the type is bool, the result should be
coerced to int, not bool.
Why it is important for statistics.mean to work with bools:
It is natural to say
Peter Norvig added the comment:
I agree with R. David Murray -- if "correct" means following the PEP 289
semantics, then
list(next(F) for _ in range(10))
should be the same as
def __gen(exp):
for _ in exp:
yield next(F)
list(__gen(iter(range(10
and indeed that i
New submission from Peter Norvig :
PEP 289 says "the semantic definition of a list comprehension in Python 3.0
will be equivalent to list(). Here is a counterexample
where they differ (tested in 3.2):
def five(x):
"Generator yields the object x five times."
f