Implicit conversion to boolean in if and while statements

Andrew Berg bahamutzero8825 at gmail.com
Tue Jul 17 10:23:27 CEST 2012


On 7/17/2012 2:08 AM, Steven D'Aprano wrote:
> The default behaviour is that every object is something, hence true-like, 
> unless explicitly coded to be treated as false-like. Since both loggers 
> and functions are objects, they are true-like unless the default is 
> overridden.
I am aware of the default behavior, but the reason for it still eludes me.

> Are you suggesting that if x doesn't exist, you want this behaviour?
I don't want that, but I am suggesting that it would be consistent with
the idea of "something or nothing".
-- 
CPython 3.3.0b1 | Windows NT 6.1.7601.17803



More information about the Python-list mailing list