[Python-Dev] Style guide (PEP 8) updated

Gerhard Häring haering_python@gmx.de
Fri, 24 May 2002 20:18:03 +0200

* Guido van Rossum <guido@python.org> [2002-05-24 12:59 -0400]:
> Barry has added (with my consent :-) some additional style guidelines
> to PEP 8.  I welcome suggestions for more guidelines.  I discourage
> arguing over what's already in the PEP (it's a BDFL pronouncement, not
> a democratic document).

I'd add that checks for None should always be done using 'is (not)
None'. Failing to do so has once bitten me. Proposed text (added to the
'Optimization and Other Programming Recommendations' section):

    Comparisions to singletons like the None builtin should always be
    done with 'is' or 'is not'. Rationale: This is slightly faster, and
    you don't have to care wether the left-hand object supports
    comparison to the singleton.


PS: IIRC the case were I was bitten was involving a __coerce__ special
method that didn't support None, but I'm not sure any more.
This sig powered by Python!
Außentemperatur in München: 15.0 °C      Wind: 2.9 m/s