Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

PEP 8 misnaming

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


facundobatista at gmail

Mar 14, 2012, 4:21 AM

Post #1 of 3 (112 views)
Permalink
PEP 8 misnaming

Hello!

In the "Maximum Line Length" section of PEP 8 it says:

"The preferred place to break around a binary operator is *after*
the operator, not before it."

And after that is an example (trimmed here):

if (width == 0 and height == 0 and
color == 'red' and emphasis == 'strong' or
highlight > 100):
raise ValueError("sorry, you lose")

In the example the line is broken after the 'and' or 'or' *keywords*,
not after the '==' *operator* (which is the nice way of doing it).

Maybe the sentence above is misleading?

Thanks!

--
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


geoffspear at gmail

Mar 14, 2012, 4:30 AM

Post #2 of 3 (107 views)
Permalink
Re: PEP 8 misnaming [In reply to]

On Wed, Mar 14, 2012 at 7:21 AM, Facundo Batista
<facundobatista [at] gmail> wrote:
> Hello!
>
> In the "Maximum Line Length" section of PEP 8 it says:
>
>    "The preferred place to break around a binary operator is *after*
> the operator, not before it."
>
> And after that is an example (trimmed here):
>
>            if (width == 0 and height == 0 and
>                color == 'red' and emphasis == 'strong' or
>                highlight > 100):
>                raise ValueError("sorry, you lose")
>
> In the example the line is broken after the 'and' or 'or' *keywords*,
> not after the '==' *operator* (which is the nice way of doing it).
>
> Maybe the sentence above is misleading?

'and' and 'or' are both binary logical operators. The fact that they
are keywords is irrelevant; the sentence isn't misleading.
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


ben+python at benfinney

Mar 14, 2012, 6:03 AM

Post #3 of 3 (105 views)
Permalink
Re: PEP 8 misnaming [In reply to]

Facundo Batista <facundobatista [at] gmail> writes:

> if (width == 0 and height == 0 and
> color == 'red' and emphasis == 'strong' or
> highlight > 100):
> raise ValueError("sorry, you lose")
>
> In the example the line is broken after the 'and' or 'or' *keywords*,

‘and’ and ‘or’ are binary operators (that also happen to be keywords).
The description is accurate and IMO not misleading.

> not after the '==' *operator* (which is the nice way of doing it).

−1. The lower-priority binding operator is the better place to break the
line. The binary logical operators bind at lower priority than the
equality operator.

--
\ “If you do not trust the source do not use this program.” |
`\ —Microsoft Vista security dialogue |
_o__) |
Ben Finney

_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.