[Python-Dev] Suggested addition to PEP 8 for context managers
Barry Warsaw
barry at python.org
Thu Apr 19 16:55:34 CEST 2012
On Apr 18, 2012, at 09:26 PM, Guido van Rossum wrote:
>On Wed, Apr 18, 2012 at 8:14 PM, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, Apr 19, 2012 at 1:06 PM, Eli Bendersky <eliben at gmail.com> wrote:
>>> (quoting GvR)
>>>> Let's change this to something more reasonable, e.g.
>>>>
>>>> """
>>>> If operators with different priorities are used, consider adding
>>>> whitespace around the operators with the lowest priority(ies). This is
>>>> very much to taste, however, never use more than one space, and always
>>>> have the same amount of whitespace on both sides of a binary operator.
>>>> """
>>>
>>> +1, a very welcome change to a piece of PEP8 I've always felt
>>> uncomfortable with. Tiny nitpick: I'd just replace the comma following
>>> "however" with a period or semicolon.
>>
>> Following or preceding? Either works, but there's a slight shift of
>> meaning depending on which punctuation gets the upgrade. What was the
>> original intent of the paragraph?
>
>I meant the semicolon to be before 'however'.
I'll make this change to the PEP. I'm not entirely sure the Yes/No examples
are great illustrations of this change in wording though. Here's the diff so
far (uncommitted):
diff -r 34076bfed420 pep-0008.txt
--- a/pep-0008.txt Thu Apr 19 10:32:50 2012 +0200
+++ b/pep-0008.txt Thu Apr 19 10:53:15 2012 -0400
@@ -305,7 +305,11 @@
``>=``, ``in``, ``not in``, ``is``, ``is not``), Booleans (``and``,
``or``, ``not``).
-- Use spaces around arithmetic operators:
+- If operators with different priorities are used, consider adding
+ whitespace around the operators with the lowest priority(ies). This
+ is very much to taste; however, never use more than one space, and
+ always have the same amount of whitespace on both sides of a binary
+ operator.
Yes::
Cheers,
-Barry
More information about the Python-Dev
mailing list