Nick Coghlan added the comment:
Changes in version 5:
- added a new reference pointing back to this tracker issue. I figure that's a
good precedent to set for future updates.
- I liked Barry's point about "Don't break backwards compatility" enough that I
moved it into its own paragraph ahead of the bulleted list and changed the
heading to "Some other good..."
- changed a few more cases of "rule" to "guideline"
- tabs vs spaces section now strongly prefers spaces, saying tabs should be
used only for legacy compatibility reasons
- changed the line length recommendation to allow up to 99 characters when it
improves readability (I kept 79 as the default recommendation, and 72 for
reflowing long blocks of text)
- rewrapped my additions to the PEP at 72 chars ;)
- encodings section no longer mentions Latin-1, referring only to UTF-8, ASCII
and non-ASCII.
- class based exception note changed to a recommendation to inherit from
Exception (this ended up leading quite well into the comment about inheritance
heirarchy design)
- we already had an admonition to avoid bare except clauses (as well as "except
BaseException:")
- dropped the "highly" from the annotation decorator recommendation
- added a note that the public/internal API guideline still applies when using
a wildcard import to republish APIs, as well as noting you should only use them
when you don't know the list of republished names in advance
I *didn't* make any changes in relation to Barry's comment about having the
commentary intermixed with the guidelines. I quite like the notion of stripping
PEP 8 down to just the essentials and having PEP 108 as "The annotated PEP 8",
but that's a bigger project than I'm prepared to tackle (heck, even the
*current* patch turned out to be a far more substantial update than I
expected!).
I'll commit this version - feel free to tweak further in the PEP repo if you
spot any mistakes :)
I deliberately left the following point out since Guido said "out of scope"
above (I wrote it before noticing that):
- Use an iterator or a "loop-and-a-half" construct rather than
repeating loop setup code in the body of the loop.
Yes::
def itervalues(x):
yield x.getvalue()
for value in itervalues(obj):
process(value)
Yes::
while True:
value = obj.getvalue()
if not value:
break
process(value)
No::
value = obj.getvalue()
while value:
process(value)
value = obj.getvalue()
----------
Added file: http://bugs.python.org/file31109/issue18472_pep_8_update5.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18472>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com