Prev: grailbrowser now running under python 2.5 (probably above too)
Next: Naming Conventions, Where's the Convention Waldo?
From: Peter Pearson on 13 Jul 2010 14:33
On 13 Jul 2010 03:16:31 GMT, Steven D'Aprano wrote:
> . . . and we rightly shake our heads at the sheer
> n00b-ness of it. Writing the explicit tests:
> if bool(myInt):
> or even:
> if myInt <> 0:
> are firmly in the same category. The only difference is that it is more
> familiar and therefore comfortable to those who are used to languages
> that don't have Python's truth-testing rules.
I have been a Python newbie for over 10 years, and would like
to mention that what's clear to Python experts is much less clear
to me. I think this might matter more than you think, since
clarity-to-the-semicompetent is an important component of
the "activation barrier" that heavily influences market share.
Names are seldom so felicitous as myInt. In practice, when
trying to read foreign code, I encounter "if x:", and poor
commenting leaves me ignorant of x's type and thus of the
exact meaning of "if x:". When I see "if x <> 0:", I get
the feeling that x is some kind of number, and the meaning
of the test is pretty clear.
And then when writing code, I usually can't confidently
retrieve the recipe for the boolean interpretation of x from
readily accessible memory, so I will write explicitly what I
mean, and thereby do a favor for the next guy to look at the
code, who is almost always a 10-year Python newbie who needs
all the clues he can get.
To email me, substitute nowhere->spamcop, invalid->net.