[issue42450] Docstrings in itertools recipes should have triple-quotes
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: peter.norvig2 priority: normal severity: normal status: open title: Docstrings in itertools recipes should have triple-quotes versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue42450> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26913] statistics.mean of bools
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 something like mean(x > threshold for x in data) and expect to get the percentage of items in data that are above threshold. -- components: Library (Lib) messages: 264670 nosy: Peter.Norvig priority: normal severity: normal status: open title: statistics.mean of bools type: behavior versions: Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26913> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14845] list(generator expression) != [list comprehension]
New submission from Peter Norvig pnor...@google.com: PEP 289 says the semantic definition of a list comprehension in Python 3.0 will be equivalent to list(generator expression). Here is a counterexample where they differ (tested in 3.2): def five(x): Generator yields the object x five times. for _ in range(5): yield x # If we ask five() for 10 objects in a list comprehension, # we get an error: F = five('x') [next(F) for _ in range(10)] Traceback (most recent call last): File stdin, line 1, in module StopIteration # But if we ask five() for 10 objects in a list(generator expr), # we get five objects, no error: F = five('x') list(next(F) for _ in range(10)) ['x', 'x', 'x', 'x', 'x'] -- components: None messages: 161023 nosy: Peter.Norvig priority: normal severity: normal status: open title: list(generator expression) != [list comprehension] type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14845] list(generator expression) != [list comprehension]
Peter Norvig pnor...@google.com 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 is the case. So the behvavior is correct and the documentation is both wrong, and rather informal/incomplete. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com