Is it possible in VS Code to add a new parameter to my function so like my functions is test(value1) and now i want to add another parameter so test(value1, value2). Can i then say everywhere where this function is called i want value 2 to be 0?
CodePudding user response:
You can use a regular expression with a capture group
test\((.*)\)
then replace using that capture group plus your default variable
test($1, 0)
using this Find and Replace (with Regular Expression enabled) this
test(value1)
test(other)
test(again)
will become
test(value1, 0)
test(other, 0)
test(again, 0)
CodePudding user response:
Uh, if you want the same variables to be passed in every time, just don't pass them in! Set them in the function rather than passing them in.
If you really need to pass them in though, you can make default parameters, like so:
def test(value1, value2 = 0):
...
test(6)
And if anytime you dont want value2 to be 0, you can specify it in the call, test(6, 1)
CodePudding user response:
Just define the value in the function instead of passing any value in if you want them to be the same in each call.