[Tutor] method could be a function warning
Phil
phillor9 at gmail.com
Wed Dec 22 23:07:36 EST 2021
On 23/12/21 12:22, Cameron Simpson wrote:
> First: "method could be a function warning" looks like a linter warning.
> Is it?
>
>
> Yes. If your linter's complaining, that is because the method does not
> use self. So it does not need to be a method. That does not not mean it
> _should _not_ be a method.
Thank you Cameron, Alan and Mats.
I didn't mention in my initial message that I had tried:
self.dummy()
@staticmethod
def dummy():
print('hello')
This quietened pylint but since I still need to prefix the call to
dummy() with self. I presumed that what I was doing still wasn't quite
correct.
Dummy(), not it's real name, doesn't access anything from the gui class.
It's used as a helper function, and it's called by several methods that
do access a gui widget. So I suppose, based on what you have said, I
should us the @staticmethod and leave it at that.
--
Regards,
Phil
More information about the Tutor
mailing list