On Wed, Jul 04, 2018 at 08:33:17PM +0300, Ivan Pozdeev via Python-Dev wrote: > >>while total != (total := total + term): > >> term *= mx2 / (i*(i+1)) > >> i += 2 > >>return total [...] > It took me a few minutes to figure out that this construct actually > checks term == 0. That's badly wrong. Hint: it's floating point code. total and term are floats, so things like this are possible: py> total = 9.5e95 py> term = 1.2 py> total + term == total True As you can see, term is nothing even close to zero. > So, this example abuses the construct to do something it's not designed > to do: perform an unrelated operation before checking the condition. Well, that's one opinion. > (Cue attempts to squeeze ever mode code here.) I would fail it in review. Okay. -- Steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4