@staticmethod or def function()?

Marko Rauhamaa marko at pacujo.net
Wed Oct 31 15:23:30 EDT 2018


Peter Otten <__peter__ at web.de>:

> Do not make changes to your code only to apeace a linter.

Precisely. Don't let a tool drive a show.

> Regarding more the general question, should I use an instance method,
> a class method, a static method, or a function? -- that is hard to
> answer without an idea what the specific task of the function/method
> is, and how strong the link to the class is.

I just always use regular instance methods. If I really want to
"disappear" self, I'll just take the function out of the class.


Marko



More information about the Python-list mailing list