Equivalent code to the bool() built-in function
Ben Finney
ben+python at benfinney.id.au
Sun Apr 17 19:46:35 EDT 2011
candide <candide at free.invalid> writes:
> Le 17/04/2011 11:46, Ben Finney a écrit :
> > What is the “shortcut” you refer to?
>
> bool(x) is nothing more than a shortcut for the following expression :
> True if x else False.
We're going around in circles. I've already pointed out that ‘bool(x)’
is what the expression you're talking about will do behind the scenes
for the ‘if x’ clause *anyway*. It's bizarre to call that a shortcut.
You seem to expect the documentation to be explicit about everything the
implementation does. Either that, or you're not making much sense.
--
\ “Pray, v. To ask that the laws of the universe be annulled in |
`\ behalf of a single petitioner confessedly unworthy.” —Ambrose |
_o__) Bierce, _The Devil's Dictionary_, 1906 |
Ben Finney
More information about the Python-list
mailing list