> Indeed, I had a bug within the past few years in a find-the-minimum search > loop, using an initial value 10x larger than anything I thought I'd ever > see. A few months later, the inputs in one case happened *all* to be > larger > than that, so it returned the bogus initial value as if it were a sensible > result. Hilarity ensued. There are few enough bugs in my code at this > age > that I take very seriously any principled gimmick that could prevent > repeating one. Alex Martelli had proposed extending the key= idea to min() and max(). The idea is to let those functions completely encapsulate the logic of searching for minimum and maximum elements: bestplayer = min(players, key=attrgetter('points')) This would work equally well with other objective functions. Raymond Hettinger ################################################################# ################################################################# ################################################################# ##### ##### ##### ################################################################# ################################################################# #################################################################
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