Implicit conversion to boolean in if and while statements

Chris Angelico rosuav at
Tue Jul 17 10:32:53 CEST 2012

On Tue, Jul 17, 2012 at 6:23 PM, Andrew Berg <bahamutzero8825 at> wrote:
> 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.

There has to be something. This way, you can use None in place of any
object, in the same way that a null pointer would be used in C; any
object is true, None isn't. What other default makes more sense?


More information about the Python-list mailing list