Reputation: 7144
I learn object-oriented programming in python 3. I've some exception, for example:
try:
self.result = (...)
except urllib.error.URLError as error:
print(error)
Generally all variables in classes are prefixed with self. Adding self before error variable:
try:
self.result = (...)
except urllib.error.URLError as self.error:
print(self.error)
causes:
SyntaxError: invalid syntax
Shall I just skip self before variables containing reason of exception?
Upvotes: 0
Views: 199
Reputation:
error
is the name you gave the exception. It is not a member of your class and thus is not prefixed with self
.
Upvotes: 4