3 ms·
Nearly everybody seems surprised by what it does, which would appear to constitute a fairly strong violation of the "principle of least surprise" that is one of
by zmmmmm 8y ago
Nearly everybody seems surprised by what it does, which would appear to constitute a fairly strong violation of the "principle of least surprise" that is one of the most cited guiding principles employed by the designers of Python. As such it would seem better to be described as an "anti-tip" or something like that.
- eesmith 8y agoIt was a feature van Rossum added in the earliest days of Python, on 14 Oct 1990, back before he fully developed his design sense. As I recall, he said added it because the implementation structure of the "for" code matched the implementation structure of the "if" code, and he felt that 'for' could use an 'else'.