python - Pylint error with abstract member variable -


i have following code:

class a(object):     def random_function(self):         print self.name      def abstract_function(self):         raise notimplementederror("this abstract class")  class b(a):     def __init__(self):         self.name = "bob"         super(b, self).__init__()      def abstract_function(self):         print "this not abstract class" 

pylint reports error:

id:e1101 a.random_function: instance of 'a' has no 'name' member

it's true, don't care because abstract. there way rid of warning without suppressing it?

thanks

it best define name in a. consider (or in couple weeks) wants inherit , implement abstract_function:

class c(a):     def abstract_function(self):         print 'his not abstract class' 

now following raise error though nothing in c seems wrong:

c = c() c.random_function() 

if using self.name in should defined there (and lets should default sensible saying not ready use):

class a(object):     name = none     def random_function(self):         print self.name 

this make code cleaner/less error prone , rid of pylint error.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -