Why PyCharm gives such a warning?

There is such an example
Example
class Person:

 def __init__(self):
pass

 def foo(self, name=None):

 def __init__(self):
 self.name = name

 result = []
 result = result.append(name)
 return result

PyCharm suggests
Screen
5afe8688d87e4276350148.png

Is this a bug in the code? Where I make that mistake? What needs to be done to fix it?
June 5th 19 at 21:15
1 answer
June 5th 19 at 21:17
Solution
The warning in the translation sounds like "hides the name 'self' from outer scope". It means that the argument self is a nested function __init__ overrides the argument is self enclosing method foo. If within that __init__ you need to seek outside self, you will not be able to do it. If you do not need, then need not worry. And if needed, self nested functions it is necessary to something to rename.
Thank you for your detailed explanation. - elenora_Carroll commented on June 5th 19 at 21:20

Find more questions by tags PyCharmPython