DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Line Wrap in Python


Omitting Backslash

You can only omitting backslash in list bracket or using parenthesis with long string.

ke = ['com.boco.esb.analysismgr.service.impl', 'com.boco.esb.dataencapsulation.service.impl', 'com.boco.esb.dataquality.service.impl']

issue_url = ('http://%s/api/issues/search?componentRoots=%s:%s'

 '&pageSize=5000&rules=%s&statuses=OPEN,REOPENED')

Mandatory Backslash

Long Variable Name

Use backslash following "=" to save space.

METHOD_RELATED_ISSUE_KEYS = \ ['checkstyle:com.puppycrawl.tools.checkstyle.checks.sizes.MethodLengthCheck', 'checkstyle:com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck', 'checkstyle:com.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck', 'checkstyle:com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck', 'checkstyle:com.puppycrawl.tools.checkstyle.checks.duplicates.StrictDuplicateCodeCheck']

List Comprehension

Backslash before "for" in list(dict) comprehension cannot be omitted.

total_issue_num = sum(get_issue_num(proj_name, pkg, issue_key) \ for pkg in pkgs)

After Operator

Backslash after operator cannot be omitted.

line_cov = sum(cov_line for (cov_line,) in lines_info) / \ sum(valid_line for (,valid_line) in lines_info)



Published

Dec 2, 2013

Last Updated

Dec 2, 2013

Category

Tech

Tags

  • line wrap 1
  • Python 136

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor