Functional Programming Aids
The modules available as functional programming aids are dealt with here. The built-in functions for algebra and logic operation are defined as convenient functions in the operator module. ‘Itemgetter’, ‘attrgetter’ and ‘methodcaller’ are available as generic methods. ‘inplace’ operators corresponding to all composite algebraic and logic operations are available as corresponding useful functions. Compact iterators formed around common functions are available in ‘itertools’. Their use is illustrated. The yield construct is for transforming a function into a corresponding generator. Going a step further ‘yield from’ chains generators for multiple sequences. Decorator provides an elegant template for nested suites. Their use is illustrated through examples. A number of readymade decorators and functions in the ‘functools’ module have been explained through illustrative examples.