On Oct 6, 8:34 pm, Neil Cerutti <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to