Inner classes
Mats Wichmann
xyzmats at laplaza.org
Wed Jun 13 15:26:19 EDT 2001
On 13 Jun 2001 14:40:07 -0400, Andrew Kuchling
<akuchlin at mems-exchange.org> wrote:
>xyzmats at laplaza.org (Mats Wichmann) writes:
>> Nonetheless, I was challenged by someone to describe how it isn't a
>> shorcoming in Python that classes don't work this way and didn't
>> convince the guy so I'm looking for a more erudite comparison.
>
>Work *what* way? It's perfectly legal to do this:
>
>class C:
> class inner:
> ... stuff for inner class
> ... stuff for class C
Right, but that doesn't work like a Java "inner class". If I've
understood correctly, that just makes up a new class, which has a name
"inner", a name that happens only to be visible inside C. But the
class referred to by "inner" isn't otherwise related to C, and does
not have access to symbols defined inside C except through
qualification, which is a pain if you want attributes of an instance
of C.
Mats
More information about the Python-list
mailing list