It is handy to be able to keep complex expressions together sometimes, when 
breaking them up would simply obscure their structure. To avoid lines getting 
long, why not take advantage of the two available screen/page dimensions to 
make their structure clearer? As a bonus, spacing out parentheses makes them 
look less of a clutter.

Examples from <https://github.com/ldo/qahirah_examples/blob/master/operators>:

A function call with complex arguments (specifying arguments by keywords is 
highly recommended here):

    rect_1_pattern = \
        qah.Pattern.create_linear \
          (
            p0 = (0, 0),
            p1 = (major_dim, 0),
            colour_stops =
                (
                    (0, rect_1_colour),
                    (1, complement(rect_1_colour)),
                )
          )

Computing a variable value (using redundant parentheses to avoid 
backslash-continuations):

    dest_rect = \
        (
            draw_bounds
        +
            Vector(col, row) * draw_bounds.dimensions
        +
            Vector(0, top_extra)
        )

>From <https://github.com/ldo/python_pixman/blob/master/pixman.py>, a complex 
>condition (with redundant parentheses again):

    if (
            not isinstance(src, Image)
        or
            mask != None and not isinstance(mask, Image)
        or
            not isinstance(dest, Image)
    ) :
        raise TypeError("image args must be Image objects")
    #end if

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to