[issue16239] PEP8 arithmetic operator examples
Ezio Melotti
report at bugs.python.org
Thu Oct 25 19:50:21 CEST 2012
Ezio Melotti added the comment:
> >- x = x * 2 - 1
> >- hypot2 = x * x + y * y
>
> Why you remove this?
As I explained in my previous message, even if valid, these are IMHO less clear than x*2 - 1 and x*x + y*y.
> >- c = (a+b) * (a-b)
> >+ c = a+b * a-b
>
> This changes the semantic.
It does indeed, but I think it's worth pointing out that misleading spacing should be avoided. Maybe a different example could be used.
> >but otoh 'x*2 - 1' is a better alternative.
>
> Can you justify this?
x*2 - 1 gives a visual hint of what gets executed first,
x * 2-1 gives a wrong/misleading hint of what gets executed first,
x * 2 - 1 gives no hint at all.
I think that providing the correct hint is better than not providing any hints (and clearly better than providing the wrong hint!).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16239>
_______________________________________
More information about the Python-bugs-list
mailing list