Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99471 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2015-11-25 19:22 +0100 |
| Last post | 2015-11-25 19:22 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: list slice and generators Peter Otten <__peter__@web.de> - 2015-11-25 19:22 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2015-11-25 19:22 +0100 |
| Subject | Re: list slice and generators |
| Message-ID | <mailman.83.1448475774.20593.python-list@python.org> |
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.
Back to top | Article view | comp.lang.python
csiph-web