Equivalent code to the bool() built-in function

Ben Finney ben+python at benfinney.id.au
Sun Apr 17 20:36:22 EDT 2011


Daniel Kluev <dan.kluev at gmail.com> writes:
> Actually, as I was curious myself, I've checked sources and found that
> `True if x else False` will _not_ call bool(), it calls
> PyObject_IsTrue() pretty much directly.

Sure. By ‘bool(x)’ I'm referring only to the implementation inside that
constructor.
> So technically these implementations are equivalent besides the fact
> that bool() is type rather than function.

What is confusing me is why on Earth this matters to the OP.
-- 
 \ “Most people don't realize that large pieces of coral, which |
 `\ have been painted brown and attached to the skull by common |
_o__) wood screws, can make a child look like a deer.” —Jack Handey |
Ben Finney


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /