4 ms·
Because "while 1:" is valid Python, but "while true:" is not ;) (gotta capitalize "True"). In addition to the GP's self deprecating sibling comment, I started
by hermitdev 5y ago
Because "while 1:" is valid Python, but "while true:" is not
;) (gotta capitalize "True").
In addition to the GP's self deprecating sibling comment, I started using Python around 2.2, before there were even "True" and "False". So, seeing a 'while 1' loop is perfectly natural to me. But, I'm also perfectly comfortable with Python's "truthiness" in more places than most people are.
As a bonus: consider "while 'false' :" as a perfectly valid start to an unbounded loop.
- chrismorgan 5y ago> consider "while 'false' :" as a perfectly valid start to an unbounded loop That sort of thing is ubiquitous in dynamically-typed languages. Even HTML: the state of boolean attributes is determined by the attribute being set, regardless of its value, so <input disabled=false> will give you a nice disabled text box. Mind you, some attributes that you might think would be boolean actually aren’t, for varying reasons good and bad, e.g. autocomplete=on|off, aria-hidden=true|false.
- fomine3 5y agoEnjoy YAML with Norway. https://news.ycombinator.com/item?id=17359376 https://news.ycombinator.com/item?id=17359376
- markrages 5y agoI learned Python around that time, when the docs said that `open()` is deprecated and to use `file()` as a constructor instead. Still unlearning that habit.
- mulmboy 5y agoCheers for the history lesson - True and False really are relatively new in Python. I wonder how common that knowledge is. http://python-history.blogspot.com/2013/11/the-history-of-bool-true-and-false.html http://python-history.blogspot.com/2013/11/the-history-of-bo... https://www.python.org/dev/peps/pep-0285/ https://www.python.org/dev/peps/pep-0285/