Answer the question
In order to leave comments, you need to log in
Why is PyCharm giving such a warning?
There is such an 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
Answer the question
In order to leave comments, you need to log in
The translation of the warning is "hides the name 'self' from the outer scope". What it means is that the self
nested function __init__
argument overrides the self
enclosing method argument foo
. If inside this __init__
you need to refer to the outer self
one, you can't do that. If you don't need it, then don't worry. And if necessary, the self
nested function must be renamed to something.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question