osdir.com


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

Pylint false positives


Marko Rauhamaa wrote:
> 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)

That's only because the definition of method() is lexically
inside the definition of __init__(). It has nothing to do
with nesting of the *class* statements.

Inner classes in Java have some special magic going on that
doesn't happen with nested classes in Python.

> the reason to use a class is that there is no handier way to create
> a method dispatch or a singleton object.

That's perfectly fine, but you can do that without creating
a new class every time you want an instance. You just have
to be *slightly* more explicit about the link between the
inner and outer instances.

-- 
Greg