It is best to define name
in A. Consider somebody (or you in couple weeks) wants to inherit from A and implements abstract_function
:
class C(A):
def abstract_function(self):
print 'This is not an abstract class'
Now the following will raise an error even though nothing in C seems to be wrong:
c = C()
c.random_function()
If you are using self.name
in A it should be defined there (and let's say it should default to something sensible saying it's not ready to use):
class A(object):
name = None
def random_function(self):
print self.name
This will make your code cleaner/less error-prone and you will also get rid of the pylint error.