nested classes

Bjorn Pettersen BPettersen at NAREX.com
Tue Jun 19 11:45:17 EDT 2001


> From: Skip Montanaro [mailto:skip at pobox.com]
> 
>     Bjorn> But that's an implementation detail only, since it works
>     Bjorn> perfectly for functions:
> 
>     Bjorn>   def foo():
>     Bjorn>       foo()
> 
> Only because at the point that foo calls itself recursively, 
> the definition
> of foo is in the module's global symbol table, assuming foo 
> is def'd at the
> module scope.  If foo is nested inside another function, it can't call
> itself directly without some help from the function it's enclosed in.

And since this was/is changed with the latest implementation, it is an
implementation detail.. no?

[snip example]

> When defining a class, the code within the class's scope is executed
> immediately, before a class object has been bound to the class's name.

Which is the implementation detail. You could easily envision an
implementation that first binds the class name to a skeleton class
object that only contains enough information for the class to be
self-referential. Other languages do this, so it's perfectly possible.
I'm not going to argue whether it's a good idea in Python or not <wink>.

-- bjorn




More information about the Python-list mailing list