have shorter development/debug cycle than compiled onesthough their programs generally also run more slowly see also interactive interpreter shutdown when asked to shut downthe python interpreter enters special phase where it gradually releases all allocated resourcessuch as modules and various critical internal structures it also makes several calls to the garbage collector this can trigger the execution of code in user-defined destructors or weakref callbacks code executed during the shutdown phase can encounter various exceptions as the resources it relies on may not function anymore (common examples are library modules or the warnings machinerythe main reason for interpreter shutdown is that the __main__ module or the script being run has finished executing iterable an object capable of returning its members one at time examples of iterables include all sequence types (such as liststrand tupleand some non-sequence types like dictfile objectsand objects of any classes you define with an __iter__(method or with __getitem__(method that implements sequence semantics iterables can be used in for loop and in many other places where sequence is needed (zip()map()when an iterable object is passed as an argument to the built-in function iter()it returns an iterator for the object this iterator is good for one pass over the set of values when using iterablesit is usually not necessary to call iter(or deal with iterator objects yourself the for statement does that automatically for youcreating temporary unnamed variable to hold the iterator for the duration of the loop see also iteratorsequenceand generator iterator an object representing stream of data repeated calls to the iterator' __next__(method (or passing it to the built-in function next()return successive items in the stream when no more data are available stopiteration exception is raised instead at this pointthe iterator object is exhausted and any further calls to its __next__(method just raise stopiteration again iterators are required to have an __iter__(method that returns the iterator object itself so every iterator is also iterable and may be used in most places where other iterables are accepted one notable exception is code which attempts multiple iteration passes container object (such as listproduces fresh new iterator each time you pass it to the iter(function or use it in for loop attempting this with an iterator will just return the same exhausted iterator object used in the previous iteration passmaking it appear like an empty container more information can be found in typeiter key function key function or collation function is callable that returns value used for sorting or ordering for examplelocale strxfrm(is used to produce sort key that is aware of locale specific sort conventions number of tools in python accept key functions to control how elements are ordered or grouped they include min()max()sorted()list sort()heapq merge()heapq nsmallest()heapq nlargest()and itertools groupby(there are several ways to create key function for example the str lower(method can serve as key function for case insensitive sorts alternativelya key function can be built from lambda expression such as lambda ( [ ] [ ]alsothe operator module provides three key function constructorsattrgetter()itemgetter()and methodcaller(see the sorting how to for examples of how to create and use key functions keyword argument see argument lambda an anonymous inline function consisting of single expression which is evaluated when the function is called the syntax to create lambda function is lambda [parameters]expression lbyl look before you leap this coding style explicitly tests for pre-conditions before making calls or lookups this style contrasts with the eafp approach and is characterized by the presence of many if statements