title: Why isn't atexit registering in python?
body: <p>I have a loop in Tkinter:</p>
  
  <pre><code>def main():
      #Global Variables
      windows = []
      buttons = []
      labels = []
      messageboxes = []
      global theme
      theme = 0
      listboxes = []
      global register
      register = []
      global path
      path = ""
      # Lotsa' Code
      Tkinter.mainloop()
  
  if __name__ == "__main__":
      main()
  
  def save_f():
      global register
      outFile = open('FobbySave.txt', 'wb')
      pickle.dump(register, outFile)
      outFile.close()
  global register     
  #At Quit
  atexit.register(save_f)
  </code></pre>
  
  <p>atexit fails. But when I try to print register it has no problem. save_f worked when I put it in the Tkinter loop, but atexit didn't. So can somebody tell me what am I doing wrong?</p>
  
  <p>P.S.</p>
  
  <h2>Sorry forgot to write atexit the first time. But it's in my code.</h2>
  
  <p>Edit: Orginal code down here</p>
  
  <pre><code>import pickle
  import atexit
  def save_f():
      global register
      outFile = open('Something.txt', 'wb')
      pickle.dump(register, outFile)
      outFile.close()
  atexit.register(save_f)
  </code></pre>