osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pylint false positives


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> Marko Rauhamaa wrote:
>> At least some of the methods of inner classes are closures (or there
>> would be no point to an inner class).
>
> In Python there is no such thing as an "inner class" in the Java
> sense. You can nest class statements, but that just gives you
> a class that happens to be an attribute of another class.
> Nothing in the nested class has any special access to anything
> in the containing class.

Lexically, there is special access:

   class C:
       def __init__(self, some, arg):
           c = self
           class D:
               def method(self):
                   access(c)
                   access(some)
                   access(arg)

IOW, inner class D is a container for a group of interlinked closure
functions.


Marko