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

Pylint false positives

Chris Angelico wrote:

> On Fri, Aug 17, 2018 at 9:49 PM, Jon Ribbens <jon+usenet at unequivocal.eu>
> wrote:
>>> "Code running directly under the class" describes every use of the class
>>> keyword (except those with an empty body). If you write:
>>>     class Spam:
>>>         x = 1
>>> you are running code under the class. This is not just a pedantic
>>> technicality,
>> Yes, it absolutely is, in this context. Having code other than
>> assignments and function definitions under the class statement
>> is extremely rare.
> Programming is heavily about avoiding duplicated work. Creating
> methods is work. Creating many identical (or similar) methods is
> duplicated work. What's wrong with using a loop to create functions?

You usually do not want many identical (or very similar) methods because 
invoking the right one is then errorprone, too, and you end up with an 
interface that is hard to maintain. At some point you may need to introduce 
subtle changes to one out of ten methods, and later someone else may 
overlook that specific angle in the documentation...

If you have many similar methods you should spend your time on reducing 
their number rather than to find shortcuts to automate their creation.

Programming is not only about avoiding duplication, it is also about stating 
your intents clearly.