title: Python 3: Pass variable from one CLASS to another
body: <p>I have a beginner problem here. I have a parent Class that contains a call to SQLite DB and to ConfigParser ini file and I want my child Class to access all those pieces of information. </p>
  
  <p>Below is my code and what I've tried so far with no success. I understand instantiation but only with minimal examples like employees/salaries lol.</p>
  
  <p>My code works if I copy all the calls to DB and config files into the child Class and it's not how it should be done, I know. Could you please help me?</p>
  
  <pre><code>class SimpleGrid(gridlib.Grid): ##, mixins.GridAutoEditMixin):
      def __init__(self, parent, log):
          gridlib.Grid.__init__(self, parent, -1)
  
          self.wxFont = "9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL"
  
          path =os.path.dirname(os.path.realpath(__file__))
          configFile = os.path.join(path , "config.ini")
  
          dbfile = os.path.join(path , "report.db")
          self.db_conn = sqlite3.connect(dbfile)
          self.theCursor =  self.db_conn.cursor()
  
          config = configparser.ConfigParser()
          config.read(configFile)
  
  
          if config.get('Network', 'taboola') == "true" and config.get('Network', 'outbrain') == "true":
              network = ""
          elif config.get('Network', 'taboola') == "true" and config.get('Network', 'outbrain') == "false":
              network = " and CAMPAIGN LIKE '%TB%'"
          elif config.get('Network', 'outbrain') == "true" and config.get('Network', 'taboola') == "false":
              network = " and CAMPAIGN LIKE '%OB%'"
          else:
              network = ""
  
          if config.get('Sort', 'value') == "Impr.":
              sort = "IMPR" 
          elif config.get('Sort', 'value') == "Clicks":
              sort = "CLICKS"
          elif config.get('Sort', 'value') == "CTR":
              sort = "CTR"  
          elif config.get('Sort', 'value') == "CPC":
              sort = "CPC"  
          elif config.get('Sort', 'value') == "eCPC":
              sort = "eCPC"
          elif config.get('Sort', 'value') == "Spent":
              sort = "SPENT"
          elif config.get('Sort', 'value') == "Revenue":
              sort = "GA_REV" 
          elif config.get('Sort', 'value') == "GA Impr.":
              sort = "GA_IMPR"  
          elif config.get('Sort', 'value') == "GA Clicks":
              sort = "GA_CLICKS"
          elif config.get('Sort', 'value') == "GA CTR":
              sort = "GA_CTR"
          elif config.get('Sort', 'value') == "Rev. /1000":
              sort = "GA_RPM"
          else:
              sort = "SPENT"
  
          #['Impr.', 'Clicks', 'CTR', 'CPC', 'eCPC', 'Spent', 'Revenue', 'GA Impr.', 'GA Clicks', 'GA CTR', 'Rev. /1000'] 
  
          if config.get('Filter', 'column') == "Campaign":
              column = "CAMPAIGN"
          elif config.get('Filter', 'column') == "Impr.":
              column = "IMPR"
          elif config.get('Filter', 'column') == "Clicks":
              column = "CLICKS"
          elif config.get('Filter', 'column') == "CTR":
              column = "CTR" 
          elif config.get('Filter', 'column') == "CPC":
              column = "CPC"  
          elif config.get('Filter', 'column') == "eCPC":
              column = "eCPC"    
          elif config.get('Filter', 'column') == "Spent":
              column = "SPENT"
          elif config.get('Filter', 'column') == "Revenue":
              column = "GA_REV" 
          elif config.get('Filter', 'column') == "GA Impr.":
              column = "GA_IMPR"
          elif config.get('Filter', 'column') == "GA Clicks":
              column = "GA_CLICKS"
          elif config.get('Filter', 'column') == "GA CTR":
              column = "GA_CTR"        
          elif config.get('Filter', 'column') == "Rev. /1000":
              column = "GA_RPM"
          else:
              column = ""
  
          if config.get('Filter', 'operator') == "Contains":
              query = "and " + column + " LIKE '%" + config.get('Filter', 'string') + "%'"
          elif config.get('Filter', 'operator') == "Doesn't Contain":
              query = "and " + column + " NOT LIKE '%" + config.get('Filter', 'string') + "%'"
  
  
          if config.get('Filter', 'operator') == "&lt;":
              query = "and " + column + " &lt; " + config.get('Filter', 'string')
          elif config.get('Filter', 'operator') == "&gt;":
              query = "and " + column + " &gt; " + config.get('Filter', 'string')
  
          #To instantiate
          queryFiltre = "SELECT * FROM Report WHERE  GA_RPM &gt; 0 " + query + network + "  and STATUS = '1' ORDER BY " + sort + " DESC"
          print(queryFiltre) 
  
          rows = self.db_conn.execute(queryFiltre)
          rowsCount = len(rows.fetchall())
  
  class TestFrame(wx.Frame):
      def __init__(self, parent, log):
          wx.Frame.__init__(self, parent, 0, "V1.0", size=(1400,800))
          self.grid = SimpleGrid(self, log)
  </code></pre>
  
  <p>What I've done so far:</p>
  
  <pre><code>class SimpleGrid(gridlib.Grid): ##, mixins.GridAutoEditMixin):
      def __init__(self, parent, log):
          gridlib.Grid.__init__(self, parent, -1)
  
  
          self.wxFont = "9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL"
          self.queryFiltre = ""
  
          def setQueryFiltre(queryFiltre):
              path =os.path.dirname(os.path.realpath(__file__))
              configFile = os.path.join(path , "config.ini")
              dbfile = os.path.join(path , "report.db")
              self.db_conn = sqlite3.connect(dbfile)
              self.theCursor =  self.db_conn.cursor()
  
              config = configparser.ConfigParser()
              config.read(configFile)
  
              #All the calls to DB and config file here
  
              return queryFiltre
  
          def getQueryFiltre(queryFiltre):
              queryFiltre = queryFiltre
  
          rows = db_conn.execute(queryFiltre)
          rowsCount = len(rows.fetchall())
  
  
  class TestFrame(wx.Frame):
      def __init__(self, parent, log):
          wx.Frame.__init__(self, parent, 0, "V1.0", size=(1400,800))
          self.grid = SimpleGrid(self, log)
  
          self.wxFont = SimpleGrid(self.wxFont)
          self.queryFiltre = SimpleGrid.getQueryFiltre()
  </code></pre>
  
  <p>But here the first error I get is the db_conn is not defined and I'm sure I will still have more to handel if this one is taken car of. In fact all the variables within the def setQueryFiltre should be accessible from within both the parent and the child Classes.</p>
  
  <p>Thank you,</p>
  
  <p>EDIT:</p>
  
  <p>With oe without self. i still get the same error
  <a href="https://i.stack.imgur.com/8B0Kb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8B0Kb.png" alt="enter image description here"></a></p>