Simple Python Quiz To Mark 100th Issue of ImportPython
Chris Angelico
rosuav at gmail.com
Fri Nov 25 04:52:11 EST 2016
On Fri, Nov 25, 2016 at 8:02 PM, Ankur Gupta <ankur at numeratelabs.com> wrote:
> Import Python Newsletter completed 2 years and 100 issues. Have a simple fun python quiz http://importpython.com/newsletter/quiz/ to mark the milestone.
With your question about laying out code, are you aware that PEP 8
specifically allows both?
"""
While sometimes it's okay to put an if/for/while with a small body on
the same line, never do this for multi-clause statements. Also avoid
folding such long lines!
"""
You have a very simple condition (actually, trivially simple - in its
exact form as given, it's always true) guarding a simple statement.
There's nothing wrong with putting that on a single line. I especially
consider this important when there are multiple parallel conditions:
if foo.x: foo.widen()
if foo.y: foo.heighten()
if foo.z: foo.deepen()
There's no point breaking these into two lines each; they show a
perfect parallel as it is, and splitting the lines would disrupt that.
ChrisA
More information about the Python-list
mailing list