I'm getting a NameError in the __del__ function of a class. I do not understand why 'open' is not accessible inside the function __del__. I am using Python 3.4.0
Python Code:
class Contoller:
...
def __del__(self):
store = {}
...
pickle.dump(store, open('data.p', 'wb'))
class MyWindow(Gtk.Window):
def __init__(self):
...
self.controller = Contoller(self)
...
self.connect("delete-event", self.quit)
...
...
def quit(self, widget, event):
del self.controller
Gtk.main_quit()
Error Message:
Traceback (most recent call last):
File "main.py", line 69, in __del__
NameError: name 'open' is not defined
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…