Python está lleno de pequeños "trucos" con los que puedes optimizar tu código y hacerlo más legible. Tal vez conozcas algunos, pero seguro aprenderás algo nuevo y útil.
2. Functions can be stored in data structures. 3. Functions can be passed to other functions! (high-order functions). 4. Functions can be nested. 5. Functions can capture local state. 6. Objects can behave like functions.
of a callable without permanently modifying the callable itself. • Any sufficiently generic functionality is a great candidate: ◦ Logging ◦ Enforcing access control and authentication ◦ Instrumentation and timing functions. ◦ Rate-limiting. ◦ Caching. ◦ More!
with variable number of arguments. • Essential for decorators and other wrappers. • If we call the function with additional arguments, args will collect them as a tuple. • Likewise, kwargs will collect extra keyword arguments as a dictionary.