On Thu, 2012-04-19 at 16:00 +0200, Peter Otten wrote: [...] > Seriously, learn that you don't need backslashes if you put the expression > into parens, precalculate parts of the expression and put them into > temporary variables -- and if that doesn't suffice to keep the code readable > and below the 80 char threshold reread the part of the PEP with the Emerson > quote ("A foolish consistency...").
I agree that where there is a backslash in a Python program, there is a better layout that doesn't have it. I wouldn't agree though that, necessarily, decomposing long expression using temporary variables improves anything. A good fluent API leads to function call chaining, far fewer variables, and far more readable code. Much of the time, not always, of course. There is currently a definite trend (*) away from 1960s FORTRAN style code structuring, to a 1980s Miranda (think Haskell and Scala) type thinking about how to structure code. There is experimental evidence in psychology of programming that declarative expression leads to more easily comprehensible code. This isn't advocacy research as much of programming research has been. Even C++ is going to a more declarative mode of expression, along with Java. Python's list comprehensions fit into this trend. (*) Which may turn out just to be just the latest fashion ready to be replaced in 2013. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor