En Thu, 18 Oct 2007 00:07:34 -0300, Steven D'Aprano <[EMAIL PROTECTED]> escribió:
> On Thu, 18 Oct 2007 03:00:56 +0000, Steven D'Aprano wrote: > >> On Wed, 17 Oct 2007 23:12:15 +0000, Paul Hankin wrote: >> >>> 'if x' doesn't test if x exists, it tests if x when cast to a bool is >>> True. >> >> To be pedantic: >> >> Python doesn't have type casts. bool(x) doesn't cast x as a bool, it >> creates a brand new Boolean object from x. > > Actually, to be even more pedantic, True and False are both singletons, > and so bool() doesn't actually create a new Boolean object but reuses the > existing ones. To be even more pedantic, 'if x' does not invoke the builtin bool(), instead it uses PyObject_IsTrue, which returns a plain C integer, not a Python bool object. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list