[openstack-dev] [style] () vs \ continuations

David Stanek dstanek at dstanek.com
Tue Nov 19 16:14:29 UTC 2013


On Mon, Nov 18, 2013 at 8:23 PM, Vishvananda Ishaya
<vishvananda at gmail.com>wrote:
>
>
> +1 to sticking something in hacking. FWIW I would probably do the following
> to avoid the debate altogether:
>
> result = self._path_file_exists(ds_browser, folder_path, file_name)
> folder_exists, file_exists, file_size_in_kb, disk_extents = result
>
> Vish
>
>
I'm working on some test code and came up with what I think is a valid use
of a line ending in \.  I'm not escaping the newline from a Python syntax
point of view.  I'm doing in inside of a string literal.  Example:

    mismatches_description = textwrap.dedent("""\
        expected = <test xmlns="http://docs.openstack.org/identity/api/v2.0
">
          <success/>
        </test>

        actual = <test xmlns="http://docs.openstack.org/identity/api/v2.0">
          <nope_it_fails/>
        </test>
    """)

This can be written in several different ways, but I think that none of
them is as clear as the trailing slash.  This is, I think, the clearest
alternative example:

    mismatches_description = textwrap.dedent("""
        expected = <test xmlns="http://docs.openstack.org/identity/api/v2.0
">
          <success/>
        </test>

        actual = <test xmlns="http://docs.openstack.org/identity/api/v2.0">
          <nope_it_fails/>
        </test>
    """).lstrip()

Would this use be forbidden too?

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
www: http://dstanek.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20131119/9d661885/attachment.html>


More information about the OpenStack-dev mailing list