[Tutor] beginning to code
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Sep 19 05:34:13 EDT 2017
On Tue, 19 Sep 2017 17:46:32 +1000, Chris Angelico wrote:
> # Display booleans differently if x is True:
> ... display flag
> else:
> ... display number
>
> which would be better represented with "if isinstance(x, bool):"
Given that True is a singleton, it is redundant to write
if isinstance(x, bool) and x:
I'd write "if x is True" if I really, honestly wanted True specifically.
--
Steven D'Aprano
“You are deluded if you think software engineers who can't write
operating systems or applications without security holes, can write
virtualization layers without security holes.” —Theo de Raadt
More information about the Python-list
mailing list