Writing in Python gives me the luxury of choosing different paradigms for similar operations. Lately I've been thinking about a minor detail that peaked my interest and am curious what others think:
Say that I have some function "f" that I will execute if some variable "v" evaluates true. Using a classical procedural approach, I might write: if v: f() I might, however, think more in a functional-programming direction. Then I might write: v and f() Interestingly, this second expression compiles smaller (though only by a little) in both Python 2.6 and 3.1, which I currently have installed. If I had thousands of such expressions, I could boast about a measurable difference but practically speaking, it is not significant. What I _am_ interested in, however, is feedback from a style perspective. What do the rest of you think about this? Have you used the second approach and, if so, what was your motivation? Is there a good/bad reason to choose one over the other? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list