Pylint false positives

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Aug 20 10:39:38 EDT 2018


On Mon, 20 Aug 2018 11:40:16 +0300, Marko Rauhamaa wrote:

>    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.

If a class' methods don't use self, it probably shouldn't be a class.

I have often wished Python had proper namespaces, so I didn't have to 
abuse classes as containers in this way :-(

(Not that I do this using "inner classes", but I do often want to use a 
class as a container for functions, without caring about "self" or 
wrapping everything in staticmethod.)



-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson




More information about the Python-list mailing list