title: Python Abstract Method Default Logic, super() method
body: <p>I am coming from the Java world and I am having a hard time understanding the super() method as it relates to abstract methods. </p>
  
  <p>I have an abstract class with an abstract method. This class' subclasses are responsible for querying my MySQL database and returning formatted reports to me. In half of the subclasses, they use the exact same logic to run the report. In the other half, each needs its own logic. Therefore I want to make <code>run_report</code> an abstract method. </p>
  
  <pre><code>class Report:
      __metaclass__ = ABCMeta
  
      def __init__(self):
          self.user = 'root'
          self.passwd = ''
          self.host = '127.0.0.0.1'
          self.port = '80'
          self.db = 'animals'        
          self.conn = mysql.connector.connect(user=self.user, password=self.passd, db=self.db, host=self.host, port=self.port)
          self.cursor = self.conn.cursor()
  
      @staticmethod
      def construct_query(query, external_data):
          finalQuery = query % external_data
          return finalQuery
  
      @abstractmethod
      def run_report(self, query):
          self.cursor.execute(self, query)
          results = self.cursor.fetchall()
          return data
  </code></pre>
  
  <p>Here is an example of an implementation of a class that uses the abstract method as is:</p>
  
  <pre><code>class SheepReport(Report):
  
      query = "SELECT COUNT(*) FROM sheep WHERE alive = 1;"
  
      def run_report(query):
          super(Report, self).run_report(query)
  </code></pre>
  
  <p>This syntax seems arcane. My code is too incomplete to test run at the moment, and I'm trying to nip errors in the bud. Am I understanding abstract methods correctly?</p>
  
  <p>By contrast, here is a class that overrides run_report:</p>
  
  <pre><code> class CowReport(Report):
  
      query = "SELECT height, weight FROM cows WHERE name IN (%s);"
  
      def run_report(self):
          finalQuery = self.construct_query(query, "'Hilda', 'Gary'");
          self.cursor.execute(self, finalQuery)
          results = self.cursor.fetchall()
          return data
  </code></pre>
  
  <p>Am I on the right track? All the examples of super() and inheritance I've seen are going over my head, I think I need someone to dumb it down for me.</p>