Boolean tests
Ethan Furman
ethan at stoneleaf.us
Tue Jul 29 20:55:48 EDT 2008
Matthew Woodcraft wrote:
> Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
>
>>No, he retracted the *insult* and restated the *advice* as a distinct
>>statement. I think it's quite worthwhile to help people see the
>>difference.
>
>
> Ben, it was quite clear from Anders' post that he knows about
> __nonzero__ . That's why the so-called advice is insulting. The
> original phrasing was just the icing on the cake.
>
> -M-
I got just the opposite -- it seems quite clear to me that Anders did
*not* know about __nonzero__, and perhaps doesn't know about
double-underscore functions in general...
Here's his quote:
> Okay, so you have this interesting object property that you often need
> to test for, so you wrap the code for the test up in a method, because
> that way you only need to write the complex formula once. I'm with
> you so far. But then you decide to name the method "__nonzero__",
> instead of some nice descriptive name? What's up with that?
His last question, "What's up with that?" is the indicator. His
comments after that, such as
> Even if we find out that C.__nonzero__ is called, what was it that
> __nonzero__ did again?
reinforce the impression that he is unaware of the double-underscore
functions and what they do and how they work. One can find out when
they are called with a simple search of the python documentation.
> Better dig up the class C documentation and find out, because there is
> no single obvious interpretation of what is means for an object to
> evaluate to true.
If you are using somebody else's code, and maybe even your own, you
should always check the docs if you don't know/can't remember what a
function does.
~Ethan~
More information about the Python-list
mailing list