On Thu, Apr 19, 2012 at 12:47 AM, Guido van Rossum <gu...@python.org> wrote:
> I don't believe PEP 8 requires whitespace around all binary operators.
> Where do you read that?

Quoting from http://www.python.org/dev/peps/pep-0008/#other-recommendations
(with elision):

Use spaces around arithmetic operators:
   No:
      i=i+1
      submitted +=1
      x = x*2 - 1
      hypot2 = x*x + y*y
      c = (a+b) * (a-b)

End quote.

In my code, whether Python or any other language, I tend to follow the
principle that whitespace is completely optional in these expressions,
but if spaces surround any operator, they should (generally) also
surround all operators of lower precedence in the same expression. So
I would quite happily accept all of the expressions above (except
'submitted', which is inconsistent), but would prefer not to see
something like:

c=(a + b)*(a - b)

which is also forbidden by PEP 8.

ChrisA
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to