Change in vdsm[master]: Modify scripts in vdsm_cli/ for PEP8 compliance

zhshzhou at linux.vnet.ibm.com zhshzhou at linux.vnet.ibm.com
Wed May 9 01:22:29 UTC 2012


Zhou Zheng Sheng has posted comments on this change.

Change subject: Modify scripts in vdsm_cli/ for PEP8 compliance
......................................................................


Patch Set 4: (1 inline comment)

....................................................
File vdsm_cli/vdsClient.py
Line 1521
PEP8 says:
"The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation. "

So I add parentheses to the long expression after a print. It can be either
print ("Pool %s status %s: %s (%s)" %
         (spUUID, status, list["message"], list["poolstatus"]))
or
print "Pool %s status %s: %s (%s)" % \
        (spUUID, status, list["message"], list["poolstatus"])

And PEP8 prefer the first style(http://www.python.org/dev/peps/pep-0008/#maximum-line-length). It gives an example:

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)

It adds parentheses to a long expression after the first 'if'. However, it doesn't gives an example on 'print long, expression'. I am not very sure which is better.  Can you give me some advice?

--
To view, visit http://gerrit.ovirt.org/4106
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I449fb43d215bb96cd12478de11b126d79d1faf41
Gerrit-PatchSet: 4
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
Gerrit-Reviewer: Adam Litke <agl at us.ibm.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Mark Wu <wudxw at linux.vnet.ibm.com>
Gerrit-Reviewer: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Gerrit-Reviewer: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list