
On 6/2/2011 11:19 AM, Barry Warsaw wrote:
On Jun 02, 2011, at 08:09 PM, guido.van.rossum wrote:
+ Continuation lines should align wrapped elements either vertically using + Python's implicit line joining inside parentheses, brackets and braces, + or using a hanging indent of double your code indention, in which case + there should be no argument on the first line. For example: + + Yes: # Aligned with opening delimiter + foo = long_function_name(var_one, var_two, + var_three, var_four) + + # Double code indention for hanging indent; nothing on first line + foo = long_function_name( + var_one, var_two, var_three, + var_four) + + No: # Stuff on first line forbidden + foo = long_function_name(var_one, var_two, + var_three, var_four) + + # 2-space hanging indent forbidden + foo = long_function_name( + var_one, var_two, var_three, + var_four)
As I mentioned to Guido, I'm not sure where the double-indent recommendation comes from, but it's entirely possible I missed that discussion. I agree with the recommendations, but think a single-indentation level looks fine. E.g.
return dict( fqdn_listname=member.mailing_list, address=member.address.email, role=role, user=path_to('users/{0}'.format(member.user.user_id)), self_link=path_to('members/{0}'.format(member.member_id)), )
or
return b'{0}://{1}:{2}/{3}/{4}'.format( ('https' if as_boolean(config.webservice.use_https) else 'http'), config.webservice.hostname, config.webservice.port, config.webservice.api_version, (resource[1:] if resource.startswith('/') else resource), )
-Barry
One place a double indent is extremely nice is for lines that initiate a new indentation, but are themselves continued: if some_function( Some, Parameters, To, Pass, ) If_True_Operations() is much more readable than: if some_function( Some, Parameters, To, Pass, ) If_True_Operations()