sorin
sorin

Reputation: 170628

Why is Eclipse python autocomplete adding the self parameter?

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 it completes the line adding the self parameter, but in Python you are not supposed to specify the self parameter when you call the methods!?

Upvotes: 0

Views: 458

Answers (1)

Jon Nylander
Jon Nylander

Reputation: 8963

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.

Upvotes: 1

Related Questions