Unresolved attribute reference
In this code:
class Utility:
def Enquote(s,quoteChar='"'):
if quoteChar == '"':
s = s.replace(quoteChar,quoteChar + quoteChar)
return quoteChar + s + quoteChar
... PyCharm is highlighting "replace" with:
Unresolved attribute reference 'replace' for class 'Utility'
... even though the code runs fine. Two questions: is this a PyCharm bug, and regardless ... can I supress this error?
As an aside, I'm a Python noob and initially wrote this with "import string" at the top of the file and the replace(s,quoteChar,quoteChar + quoteChar) syntax, and that also was reported the same way.
Please sign in to leave a comment.
It appears this was caused by my failure to understand Python's awkward workaround for its lack of a "this" or "self" or "me" operator. It would never have occurred to me that every method signature I write in a class must have an initial self argument. That's ugliness in the name of ideological purity if ever I saw it ...