Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Implicit conversion to boolean in if and while statements (http://www.velocityreviews.com/forums/t948129-re-implicit-conversion-to-boolean-in-if-and-while-statements.html)

Chris Angelico 07-15-2012 08:47 AM

Re: Implicit conversion to boolean in if and while statements
 
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


All times are GMT. The time now is 05:42 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.