Re: Implicit conversion to boolean in if and while statements
On Sun, Jul 15, 2012 at 6:34 PM, Andrew Berg <firstname.lastname@example.org> 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.
|All times are GMT. The time now is 12:49 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.