title: Where to initialize an instance of a class in a multiple file python code?
body: <p>I working on a project that is broken into multiple files, and while I know my issue is that I'm not initializing an instance of the class I'm trying to use, I can't figure out where to do so. The two files are below - the DataLayer and the main file. The issue in question is under the first button - I'm passing data entered by the user to the DataLayer and attempting to use a method (d_read_from_pandas_all) in that class. The method's only parameter is &quot;self.&quot; What am I missing here?</p>
  <pre><code>from DataLayer import *
  from ViewLayer import *
  class NotebookDemo(Frame):
  
      def __init__(self, isapp=True, name='notebookdemo'):
          Frame.__init__(self, name=name)
          self.pack(expand=Y, fill=BOTH)
          self.master.title('Inventory Data Cleaner')
          self.isapp = isapp
          self._create_widgets()
  
      def _create_widgets(self):
          self._create_demo_panel()
  
      def _create_demo_panel(self):
          demoPanel = Frame(self, name='demo')
          demoPanel.pack(side=TOP, fill=BOTH, expand=Y)
  
          # create the notebook
          nb = Notebook(demoPanel, name='notebook')
          nb.enable_traversal()
  
          nb.pack(fill=BOTH, expand=Y, padx=2, pady=3)
          self._create_descrip_tab(nb)
          self._create_view_tab(nb)
          self._create_text_tab(nb)
  
  
  
      def _create_descrip_tab(self, nb):
          # frame to hold contentx
          frame = Frame(nb, name='descrip')
  
          # widgets to be displayed on 'Description' tab
  
          docName = tk.StringVar()
          docLabel = tk.Label(frame, text = 'enter cruise document name')
          docEntry = tk.Entry(frame, textvariable = docName)
  
          btn = Button(frame, text='Load', underline=0,
             command=lambda: [DataLayer(str(docName)), DataLayer.d_read_from_pandas_all()])
          #
  
          # position and set resize behaviour
          btn.grid(row=1, column=0, pady=(2, 4))
          docLabel.grid(row = 0, column = 0, pady = (2,4))
          docEntry.grid(row = 0, column = 1, pady = (2,4))
  
          frame.rowconfigure(1, weight=1)
          frame.columnconfigure((0, 1), weight=1, uniform=1)
  
          # add to notebook (underline = index for short-cut character)
          nb.add(frame, text='View Data', underline=0, padding=0)
  
  
      # =============================================================================
      def _create_view_tab(self, nb):
          # Populate the second pane. Note that the content doesn't really matter
          frame = Frame(nb, name=&quot;view&quot;)
          btn1 = Button(frame, text='Click here to view data', underline=0,
                        command=lambda:[DataLayer.d_read_from_pandas_all(self, docName), ViewLayer.create_display_table(self,frame), ViewLayer.viewTable(self)])
  
          btn1.grid(row=1, column=0, pady=(2, 4))
  
          nb.add(frame, text='Check Data', underline=0, padding=2)
  
      # =============================================================================
      def _create_text_tab(self, nb):
          # populate the third frame with a text widget
          frame = Frame(nb)
  
          txt = Text(frame, wrap=WORD, width=40, height=10)
          vscroll = Scrollbar(frame, orient=VERTICAL, command=txt.yview)
          txt['yscroll'] = vscroll.set
          vscroll.pack(side=RIGHT, fill=Y)
          txt.pack(fill=BOTH, expand=Y)
  
          # add to notebook (underline = index for short-cut character)
          nb.add(frame, text='Text Editor', underline=0)
  
  
  if __name__ == '__main__':
      NotebookDemo().mainloop()
  </code></pre>
  <pre><code>import pandas as pd
  
  
  class DataLayer:
      def __init__(self, filename):
          self.filename = filename
  
  
  
  
      def d_read_from_pandas_all(self):
          global df
          df = pd.read_csv(self.filename, index_col=0)
          print(df.head(10))
  
          return df
  </code></pre>