Re:The tyranny of the Hollerith punched card
by tamana on Monday June 06, 2016 @10:52AM
(#11847186)
80col is narrow for Java because Java has very long method names, explicit tyle declarations, and class names on static methods.
[ Parent
| on HN ]
Re:The tyranny of the Hollerith punched card
by Karunamon on Monday June 06, 2016 @12:06PM
(#11847773)
Python too, because you're forced to indent. One line of moderate length explanatory text out to console in the middle of an if: block, and you have to resort to silly tricks[1] to remain PEP8 compliant.
[1]: https://tkware.info/2016/05/08/a-case-for-increasing-pep8-li...
If you weren't forced to indent when appropriate, and chose not to, I think that would damage readability even more.
There are contexts when Python doesn't force you to, such as the example the article shows as "ways [that] actually make our code less obvious and less readable":
err("HTTP 403 Forbidden -"
" Does your bitbucket user have rights to the repo?\n")
But if you indent it properly, I don't think it's less readable than the extra-long-line-with-scrolling: err("HTTP 403 Forbidden -"
" Does your bitbucket user have rights to the repo?\n")
The other example, build_url = "{url}/pipelines/{pipeline}/jobs/{jobname}/builds/{buildname}".format(
url=os.environ['ATC_EXTERNAL_URL'],
pipeline=os.environ['BUILD_PIPELINE_NAME'],
jobname=os.environ['BUILD_JOB_NAME'],
buildname=os.environ['BUILD_NAME'],
)
could perhaps be written as urltmpl = "{url}/pipelines/{pipeline}/jobs/{jobname}/builds/{buildname}"
build_url = urltmpl.format(
...
or like this: build_url = "/".join((os.environ['ATC_EXTERNAL_URL'],
"pipelines", os.environ['BUILD_PIPELINE_NAME'],
"jobs", os.environ['BUILD_JOB_NAME'],
"builds", os.environ['BUILD_NAME']))
Re:The tyranny of the Hollerith punched card
by Karunamon on Monday June 06, 2016 @06:06PM
(#11850828)
The reason I complain about that err() example is because it relies on very un-pythonic behavior. You're one stray comma away from sending in a tuple rather than a silently concatenated string.
(Coincidentally, this is why the separator there is a dash, rather than the more grammatically correct comma)
And I thank you for the other examples of ways to handle the URL, but again we've moved into making changes for very minor benefit just to please the analyzer, rather than the human reading the code.