[openstack-dev] [solum] pep8 - splitting expressions

Jay Pipes jaypipes at gmail.com
Tue Sep 9 20:59:33 UTC 2014


On 09/09/2014 03:05 PM, Gilbert Pilz wrote:
> I have a question with regards to splitting expressions in order to
> conform to the pep8 line-length restriction. I have the following bit of
> code:
>
>              res = amodel.Assemblies(uri=common.ASSEM_URI_STR %
>                                      pecan.request.host_url,
>                                      name='Solum_CAMP_assemblies',
>                                      type='assemblies',
>                                      description=common.ASSEM_DESC_STR,
>                                      assembly_links=a_links,
>
> parameter_definitions_uri=common.ASSEM_PARAM_STR %
>                                      pecan.request.host_url)
>
> The line that assigns a value to 'parameter_definitions_uri' is (as you
> might be able to tell) too long. What is the best way to split this
> expression up?

     pdu = common.ASSEM_PARAM_STR % pecan.request.host_url
     res = amodel.Assemblies(uri=common.ASSEM_URI_STR %
                             pecan.request.host_url,
                             name='Solum_CAMP_assemblies',
                             type='assemblies',
                             description=common.ASSEM_DESC_STR,
                             assembly_links=a_links,
                             parameter_definitions_uri=pdu)

Best,
-jay



More information about the OpenStack-dev mailing list