Moment of zen

Moment of zen: Code is written once but read over and over. Fewer is clearer:

Figure 7.1: Moment of Zen

Comprehensions are often more readable than the alternative. However it's possible to over-use comprehensions. Sometimes a long or complex comprehension may be less readable than the equivalent for-loop. There is no hard-and-fast rule about when one form should be preferred, but be conscientious when writing your code and try to choose the best form for your situation.

Above all your comprehensions should ideally be purely functional — that is they should have no side effects. If you need to create side effects, such as printing to the console during iteration, use another construct such as a for-loop instead.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset