This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients daniel.urban, docs@python, eric.araujo, ncoghlan, r.david.murray, terry.reedy
Date 2011-06-25.00:28:36
SpamBayes Score 4.3810133e-09
Marked as misclassified No
Message-id <1308961717.22.0.539342039803.issue12374@psf.upfronthosting.co.za>
In-reply-to
Content
Most of my thoughts on this topic can be found at http://svn.python.org/view/sandbox/trunk/userref/ODF/ (that was written ~2.5, so some parts of it are a little dated, but the Essential Concepts section is still fairly accurate).

The most relevant part to the current discussion is 1.5:

1.5 Classes and Functions are Defined at Runtime
In static language such as Java or C++, function and class definitions are essentially directives to the language compiler regarding the nature of certain identifiers. While class and function definition statements still have implications for the compilation stage in Python, these definitions are also first class statements that are executed at runtime, just like any other statement. While the code within the function or class definition statement is compiled at compile time, the actual definition of the function or class does not occur until the statement is executed at runtime.
In top level code, this distinction usually doesn't matter, but it has some significant implications when class and function definitions are placed inside a function. Doing so means that a new class or a new function is defined every time the containing function is executed. This means that not only is it possible to have factory functions that create new class instances (as is common in all object-oriented languages), but it is also possible to have factory functions that create new classes or new functions. Another key feature of nested functions is that they employ lexical scoping, allowing nested functions to see identifiers defined in outer scopes.
History
Date User Action Args
2011-06-25 00:28:37ncoghlansetrecipients: + ncoghlan, terry.reedy, eric.araujo, r.david.murray, daniel.urban, docs@python
2011-06-25 00:28:37ncoghlansetmessageid: <1308961717.22.0.539342039803.issue12374@psf.upfronthosting.co.za>
2011-06-25 00:28:36ncoghlanlinkissue12374 messages
2011-06-25 00:28:36ncoghlancreate