[Erik Max Francis] > ... > The Python FAQ, for instance, suggests x ? a : b can be reliably > substituted with > > (x and [a] or [b])[0] > > which definitely works ([a] and [b] are singleton lists and always > evaluate true), but it makes the meaning unclear enough to defeat the > purpose of wanting to use a conditional operator in the first place. LOL! I "invented" that "idiom" for Python in the early 90's, in a silly thread where Steven Majewski and I tortured each other with the worst constructs we could dream up. If you ever see production code that actually *uses* it, I encourage you to kill the author. > ... > On a vaguely related subject, why is there no Boolean type in Python? Because Guido didn't feel one was needed. Still doesn't, last I heard. Barry Warsaw is a big fan of adding one, though, and since he got "print >> file" in, there's no known lower limit on the uselessness of the ideas he can sell <wink>. next-up:-how-come-there-isn't-a-case-stmt?-ly y'rs - endless tim
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