One added note:

>> if greeting == True:
>> if greeting is True:
>
> This one is based on the preference for identity checks when singletons are
> involved, rather than equality tests.  Being composed of English words, the
> latter is also more readable.  It's the same reason why you would do identity
> checks against None or enum values.

There is more to it that that -- == can be overridden for a particular
class. So doing:

X == None

Could yield surprising results if __eq__ has been defined for the
class X is bound to at the moment. Numpy arrays are a common case for
me.

As None is often used to mean undefined, X could be any type. Granted,
in your code, you likely know what type(s) X is likely to be, but it's
a good habit to get in to.

-Chris


>
>> Please don't misunderstand me: I dislike the above intensely, but it's an
>> emotional response based on 10-15 years of doing things the other way. I'm
>> interested in arguments that don't include things like "it's pythonic" (which
>> some people consider a derogatory term ;-)), or "just because", I trust that
>> the stuff in pep8 was done with specific reasoning in mind, but I'm feeling
>> rather useless at giving that reasoning and I'm hoping you can help :-)
>
> I hope those explanations give you the basis for why the choices were made.
> They aren't arbitrary, although folks can and do disagree.  It's much more
> important that your project comes up with its own guidelines and applies them
> self-consistently.  For example, I have my own small set of refinements on top
> of PEP 8.  I'm not providing a link because they're a bit out of date
> w.r.t. Python 3. ;)
>
> Cheers,
> -Barry
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to