Tim Peters <tim.one@comcast.net>: > There's nothing reprehensible about, e.g., > > days_in_year = 365 + is_leap(year) This is bug-prone, because it relies on is_leap always returning a "normalised" boolean value. I don't think it would be a bad thing if you had to write it days_in_year = 365 + ord(is_leap(year)) or, even better, days_in_year = 365 + bit(is_leap(year)) where bit() is a function that takes a boolean (and only a boolean) and returns 0 or 1. > print [("off", "on")[switch] for switch in switch_list] No, no, what you really mean is print [{False:"off", True:"on"}[switch] for switch in switch_list] or perhaps print ["on" if switch else "off" for switch in switch_list] and similarly days_in_year = 365 + 1 if is_leap(year) else 0 (Yes, I know that one's already been rejected. I can't stop liking it, though...) Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
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