Refactoring a function definition
I am using Pydev on Eclipse to write python code. I am new to Pydev and to Eclipse. I love the feature where by I can use rightClick -> Refactoring -> Rename... to rename a variable.
I was wondering if there is something similar to change a function everywhere in the project, if I change its definition.
For example, suppose I initially have:
def myFunction(a, b):
body of the function
return blah
I use this function in other files of the project. Say,
thisVar = myFunction(a, b)
Now I feel the need to change the function definition to account for an additional parameter.
def myFunction(a, b, c):
body of the function
return blah
Is there something in eclipse or pydev such that it will automatically change
thisVar = myFunction(a,开发者_Python百科 b)
to
thisVar = myFunction(a, b, c)
Thanks for your help.
no IDE may support this as when you call a function it requires variable which may not be the c
all the time,
what I suggest is keep the parameter c as optional like
thisVar = myFunction(a, b, c = None)
and when you actually realize that it requires c then you can call those statements by using 3 parameters or myFunction(10,20, c = 2000)
I don't think refactoring methods exist in Pydev of Eclipse. For reasons to why, please see here for reference... it has to do with the construct of python variables
why doesn't eclipse-python have magic refactor?
I know this is 4 years old, but Eclipse for java can refactor method definitions and change arguments. As far as I know, Pydev doesn't include support for python's functions
精彩评论