Python

Python Iterator and Iterable Basics

A Python iterator is an object that enables the elements inside a collection object, such as a lists, tuples, dictionaries, and strings, to be looped over and accessed one at a time. Such collections are called iterables and their common characteristic is that they can provide an iterator.

Python Inner Functions

Python inner functions, also known as nested functions, are functions defined within the scope of another function. Inner functions are particularly useful as helper functions, which encapsulate logic only useful within the context of another function, and as factory functions, which create and return other more specialized functions.

Multiple Return Values in Python Functions

While functions typically return a single value or no value at all, there are cases in which having multiple return values in Python functions is desirable. It is a general programming best-practice to have each function be responsible for doing one thing only, and therefore those multiple returned values should be closely related to a single concept.

Python Docstring

A Python docstring is a string that appears at the beginning of a function and serves as a human-readable explanation of a function’s purpose, behavior, and usage.