Names changed to protect the guilty

MonkeeSage MonkeeSage at gmail.com
Sat Oct 7 04:26:02 CEST 2006


On Oct 6, 8:34 pm, Neil Cerutti <horp... at yahoo.com> wrote:
> And in the original case, I'd agree that "if X.has_key():" is
> quite clear, already yielding a boolian value, and so doesn't
> need to be tested for if it's False. But I wouldn't like to test
> for an empty list or for None implicitly.

I agree that predicates are explicit in themselves, if they are named
intuitively like "has_key". I assumed that the OP was upset about "is
False" not that an explicit check was done on a predicate method.

On Oct 6, 8:38 pm, Gabriel Genellina <gagsl... at yahoo.com.ar> wrote:
> It's not about style or being pythonic: a condition may be false, but
> not the False object itself, so writing
> if something is False:
> is the wrong way to test if something is false (isn't clear? :) )

Yes, I understand, and it's true that in a mixed context it could bite
you (or you could check equality rather than identity), but assuming a
strictly boolean context you don't have that problem (or perhaps you
even *want* to differentiate between False, None and 0 in a mixed
context).

Ps. I mostly use the "if (not) cond" form. But I take the style guide
as a, well, *guide*, rather than a style *law* and I tend to get
annoyed when people get religious about things like that. Subjective
taste, be it GvR's or the Pope's, is -- subjective. On the other hand,
if lightening is flashing and seas are parting and stuff, I don;t tend
to argue too much in that case. ;)

Regards,
Jordan




More information about the Python-list mailing list