Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25343
| References | <500280A6.6070608@gmail.com> |
|---|---|
| Date | 2012-07-15 18:47 +1000 |
| Subject | Re: Implicit conversion to boolean in if and while statements |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2134.1342342028.4697.python-list@python.org> (permalink) |
On Sun, Jul 15, 2012 at 6:34 PM, Andrew Berg <bahamutzero8825@gmail.com> wrote: > Converting 0 and 1 to False and True seems reasonable, but I don't see > the point in converting other arbitrary values. It's for convenience. Unfortunately, not all languages treat all types the same way. It's very handy, though, to be able to use if not foo: foo = some_initializer when foo starts out as, say, None. Or []. Or, in fact, any other "empty" value. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2012-07-15 18:47 +1000
csiph-web