[Python-Dev] Suggested addition to PEP 8 for context managers

Chris Angelico rosuav at gmail.com
Thu Apr 19 17:05:24 CEST 2012


On Fri, Apr 20, 2012 at 1:00 AM, Éric Araujo <merwok at netwok.org> wrote:
> Hi,
>
>> +- 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.
>
> Does “this is very much to taste” means that it’s a style judgment where
> each team or individual may make different choices?  I’m not a native
> speaker and I’m not sure about the intended meaning.

Yes. It's like writing instructions for how to make a cup of tea. You
might want to put in one spoon of sugar, someone else might prefer
two. On the instructions, you simply write "Add sugar to taste", and
that's what this is drawing analogy with. The PEP, as then written,
would happily accept all of these:

x = y*2+z*3
x = y*2 + z*3
x = y * 2 + z * 3

but would advise against:

x =y*2  +  z* 3

ChrisA


More information about the Python-Dev mailing list