问题
Not sure I get this but I got a validation error from pyLint saying:
Redefining name 'a' from outer scope (line 443) (redefined-outer-name)
Redefining name 'b' from outer scope (line 444) (redefined-outer-name)
The code is like this:
a = 98 # line 443
b = 90 # line 444
def prodNr(a, b):
"""Definiera prodNr"""
return a * b
result = prodNr(a, b)
ANSWER = result
Could anyone please give me a clue on how to get rid of the validation error?
回答1:
Call you variables something else:
def prodNr(a, b):
"""
Definiera prodNr
"""
return a * b
i = 98
j = 90
result = prodNr(i, j)
You can use any name for the variables you pass in they don't have to be called a and b. It does not affect your code either way as the variables are passed into the function, it would be a problem if you had a and b in multiple places in your code and you decided to change a to var_a but forgot to change it in one or two places then you would get different output to what you would expect.
来源:https://stackoverflow.com/questions/28843079/validation-error-redefined-outer-name-from-outer-scope