being processed inside the generator in additiongenerators in and later also support throw(typemethod to raise an exception inside the generator at the latest yieldand close method that raises special generatorexit exception inside the generator to terminate the iteration entirely these are advanced features that we won' delve into in more detail heresee reference texts and python' standard manuals for more informationand watch for more on exceptions in part vii note that while python provides next(xconvenience built-in that calls the __next__(method of an objectother generator methodslike sendmust be called as methods of generator objects directly ( send( )this makes sense if you realize that these extra methods are implemented on built-in generator objects onlywhereas the __next__ method applies to all iterable objects--both built-in types and user-defined classes also note that python introduces an extension to yield-- from clause--that allows generators to delegate to nested generators since this is an extension to what is already fairly advanced topicwe'll delegate this topic itself to sidebarand move on here to tool that' close enough to be called twin generator expressionsiterables meet comprehensions because the delayed evaluation of generator functions was so usefulit eventually spread to other tools in both python and xthe notions of iterables and list comprehensions are combined in new toolgenerator expressions syntacticallygenerator expressions are just like normal list comprehensionsand support all their syntax --including if filters and loop nesting--but they are enclosed in parentheses instead of square brackets (like tuplestheir enclosing parentheses are often optional)[ * for in range( )[ list comprehensionbuild list ( * for in range( )generator expressionmake an iterable at in factat least on functionality basiscoding list comprehension is essentially the same as wrapping generator expression in list built-in call to force it to produce all its results in list at oncelist( * for in range( )[ list comprehension equivalence operationallyhowevergenerator expressions are very differentinstead of building the result list in memorythey return generator object--an automatically created iterable this iterable object in turn supports the iteration protocol to yield one piece of the result list at time in any iteration context the iterable object also retains gengenerator functions and expressions