be called by you; • Your objects can behave like the built-in types; • They allow your objects to interact with basic language constructs, such as: * Iteration, collections, attribute access, operator overloading, function and method invocation, object creation and destruction, string representation and formatting, managed contexts…
concise and effective way to build data structures; • More performatic; • Genexp saves memory because it yields items one by one using the iterator protocol;
versa); • An iterator retrieves item from a collection, while a generator can produce items "out of thin air"; • Python uses generators in many places (e.g. range())