[Sugar-devel] Coding style: line continuations

C. Scott Ananian cscott at laptop.org
Thu Nov 11 14:27:15 EST 2010


On Fri, Nov 12, 2010 at 2:09 AM, Simon Schampijer <simon at schampijer.de>
wrote:
> In general I would do what the spec says if there is no good reason not to
> [1]. The example they have does not really handle all the cases, though.
> Neither pep8 nor pylint does favor any formatting. So I guess we are a bit
> free here.

I belive PEP8's example is rather definitive:

"... Make sure to indent the continued line appropriately.  The preferred
place to break around a binary operator is *after* the operator, not before
it.  Some examples:

   class Rectangle(Blob):

       def __init__(self, width, height,
                    color='black', emphasis=None, highlight=0):
           if width == 0 and height == 0 and \
              color == 'red' and emphasis == 'strong' or \
              highlight > 100:
               raise ValueError("sorry, you lose")
           if width == 0 and height == 0 and (color == 'red' or
                                              emphasis is None):
               raise ValueError("I don't think so -- values are %s, %s" %
                                (width, height))
           Blob.__init__(self, width, height,
                         color, emphasis, highlight)

I don't think there's any ambiguity there, actually.
  --scott

-- 
                         ( http://cscott.net/ )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101112/b8d0bf5e/attachment.html>


More information about the Sugar-devel mailing list