hello david hello __qualname__ 'hello hello __qualname__ 'hello hello can bind func to other names hello __qualname__ 'hello __qualname__ 'hello hello __qualname__ 'hello one of the reasons that functions are useful is that they isolate state lexicallyand avoid contamination of enclosing namespaces this is limited form of nonmutability in that (by defaultnothing you do within function will bind state variables outside the function of coursethis guarantee is very limited in that both the global and nonlocal statements explicitly allow state to "leak outof function moreovermany data types are themselves mutableso if they are passed into function that function might change their contents furthermoredoing / can also change the "state of the worldand hence alter results of functions ( by changing the contents of file or database that is itself read elsewherenotwithstanding all the caveats and limits mentioned abovea programmer who wants to focus on functional programming style can intentionally decide to write many functions as pure functions to allow mathematical and formal reasoning about them in most casesone only leaks state intentionallyand creating certain subset of all your functionality as pure functions allows for cleaner code they might perhaps be broken up by "puremodulesor annotated in the function names or docstrings closures and callable instances there is saying in computer science that class is "data with operations attachedwhile closure is "operations with data attached in some sense they accomplish much the same thing of putting logic and data in the same object but there is definitely philosophical difference in the approacheswith classes emphasizing mutable or rebindable stateand closures emphasizing immutability and pure functions neither side of this divide is absolute--at least in python --but different attitudes motivate the use of each closures and callable instances