开发者

Why is Eclipse python autocomplete adding the self parameter?

开发者 https://www.devze.com 2023-04-10 07:11 出处:网络
I recently started to use PyDev and the method autocomplete seems to be stupid: I select the method name in the dropdown list, click enter and 开发者_如何学JAVAit completes the line adding the self pa

I recently started to use PyDev and the method autocomplete seems to be stupid: I select the method name in the dropdown list, click enter and 开发者_如何学JAVAit completes the line adding the self parameter, but in Python you are not supposed to specify the self parameter when you call the methods!?


If you are writing a new method in a Class, it does this. But not if you have previously decorated with for example @staticmethod, this is what gets autocompleted for me in PyDev:

def normal_method(): #nothing gets autoinserted
    pass

class Foo:
    def instance_method(self): #self gets autoinserted
        pass

    @staticmethod
    def static_method(): # nothing is inserted
        pass

    @classmethod
    def class_method(cls): #cls is autoinserted
        pass

Are you sure that you're not in a class when this happens? If you are, then I think it is a reasonable behavior, if not, PyDev is bugging out for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号