On Friday, November 25, 2016 at 3:22:30 PM UTC+5:30, Chris Angelico wrote: > On Fri, Nov 25, 2016 at 8:02 PM, Ankur Gupta <an...@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
Hey ChrisA, I see merit in what you are saying. I should probably have used an example with multiple statements perhaps to draw a better distinction. My bad. Quiz is now out so would be unfair for those who attempted it. Regards, Ankur -- https://mail.python.org/mailman/listinfo/python-list