Pylint false positives

Marko Rauhamaa marko at pacujo.net
Mon Aug 20 15:54:32 EDT 2018


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

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

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


Marko



More information about the Python-list mailing list