[Tutor] Need help printing a pickled data

Matt D md123 at nycap.rr.com
Tue Jun 25 00:05:37 CEST 2013


I have been unable to find a way to write pickled data to text file.
My last attempt was to add the last two lines:

 # the dataevent class -- stores the data that gets transmitted when the
event occurs.
#it is the data in text fields, stored in self.data as a dictionary,
which is basically a c++ map
#One of these classes gets created whenever an event occurs.
class DataEvent(wx.PyEvent):
    # the values of the text fields get passed into the constructor
inside of data
    def __init__(self, data):
        wx.PyEvent.__init__(self)
        # this line *binds* this class to a certain type of event,
wxDATA_EVENT
        self.SetEventType (wxDATA_EVENT)
        # and this is the actual data
        self.data = data
        with open('mypicklelog.txt','a') as log:
            log.write(self.data)

I cant figure out why these last two line dont write to the .txt file
after the program has received the pickled Python dictionary?  Very
stumped.


More information about the Tutor mailing list