[Tutor] beginning to code
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Sep 13 04:16:55 EDT 2017
On Tue, 12 Sep 2017 23:20:21 -0700, Rick Johnson wrote:
> Steven D'Aprano wrote:
>> Rick Johnson wrote:
>>
>>
>> > But just because we have been trained that the implicit `if x:` is
>> > shorthand for the reasonable `if bool(x) == True:`
>>
>> That's not reasonable. bool(x) already returns a True or False flag,
>> comparing it to True is superfluous.
>
> So what? That's a simple matter of translating source code to byte code
Who cares about the byte code? We don't read or write byte code.
The *source code* you wrote is dumb. It displays an appalling lack of
understanding of Python's semantics, and poor reasoning about even the
simplest logical tests. Here's another person's comments:
"When I see someBool == true, I can't help but feel like the programmer
hasn't internalized the idea of evaluation, which is a pretty fundamental
deficiency."
https://softwareengineering.stackexchange.com/posts/12828/revisions
You might as well write:
if (x is True) and (True is True): # just in case True is False
In plain English terms, you are doing the equivalent of saying:
"Is (is that true?) true?"
Who talks like that?
Why should we write code like that?
--
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