removing nested iffs

Josh Benner sjbenner at gmail.com
Fri Jul 29 22:14:02 CEST 2011


On Fri, Jul 29, 2011 at 1:07 PM, Wolfgang Rohdewald
<wolfgang at rohdewald.de>wrote:

> On Freitag 29 Juli 2011, Josh Benner wrote:
> > if args.build not None:
>
> which python version understands this?
>
> --
> Wolfgang
>

Apparently the version running in my head understands it ;-)

Sorry about that how about this (replacing 'not' with 'is not' where
appropriate):


def format_rsync_src_string(args, server="RSYNC"):
    """ Format an rsync source directory string. """
    if args.server is None:
        raise CopyNightlyError("No rsync server provided.")
    src = "{0}::".format(args.server)
    if args.project is not None:
        src += "{0}/".format(args.project)
        if args.version is not None:
                src += "{0}/".format(args.version)
                if args.build is not None:
                    src += "Build {0}".format(args.build)
    return src
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110729/421e3db2/attachment.html>


More information about the Python-list mailing list