nested classes
Remco Gerlich
scarblac at pino.selwerd.nl
Tue Jun 19 06:27:55 EDT 2001
Bjorn Pettersen <BPettersen at NAREX.com> wrote in comp.lang.python:
> > From: Mats Wichmann [mailto:xyzmats at laplaza.org]
> > Java and C++ are compiled. The class definition is instructions to
> > the compiler, and can be self-referential, because the /reference/ is
> > not going to happen until the class is loaded - no inconsistency. Not
> > so for Python, the class definition is code that is actually run to
> > build the class object, and before that object has been built, there's
> > nothing to refer to yet, as Alex said.
>
> But that's an implementation detail only, since it works perfectly for
> functions:
>
> def foo():
> foo()
The difference is that a class is executed when it's defined, and a function
is executed when it is called. By the time the function is called, 'foo'
exists, of course.
--
Remco Gerlich
More information about the Python-list
mailing list