[Aahz] > I'm curious: why you didn't use None as the initial value or use some > other hack to avoid initializing with a specific number? In 2.3, None compares less than anything else; the search loop required that the initial value compare larger than anything else (although I wouldn't have been comfortable with relying on that None compares smaller either, since that's non-obvious version-specific behavior). I've since tended to write these kinds of loops as: global_min = None ... if global_min is None or score(candidate) < global_min: global_min = score(candidate) do stuff appropriate for a new local minimum but it's easy to forget the "global_min is None" clause -- in which case, *because* None compares less than everything else, the "if" test never passes. A conventional spelling for universal smallest and largest objects would allow for a very clean and clear solution. I'm reminded that we introduced "print >> f" partly because most people made mistakes in details when trying to temporarily rebind sys.stdout "by hand". Complex search loops are brittle in the details too. So I'll let Barry propose that a bare ">>" mean "biggest" and a bare "<<" mean "smallest" <wink>. >>> << < >> True
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