def print_name(your_name = "Anonymous Andy"):
print("Hello, " + your_name)
def your_name():
# This function has same name as variable in above function
return None
print_name() # Prints "Hello, Anonymous Andy"
print_name("World") # Prints "Hello, World"
Above code is written for academic purpose to learn Python, and not for production. Pylint (2.14.0) warns me:
1:15: W0621: Redefining name 'your_name' from outer scope (line 4) (redefined-outer-name)
Question
- I assume Pylint is warning me "Hey you are redefining the your_name function". Is this understanding correct?
- If above understanding is correct then I think Pylint is wrong, and I think I am redefining the your_name variable which is local to the print_name function's scope. Is this understanding correct?
- If my above understandings are correct, I am further puzzled because I don't think a famous program like Pylint would raise such false alarm. The fact that it raised an alarm is not wrong, but the message looks like a lie because I'm not redefining anything from outer scope. Am I missing something?