On 06/24/2013 06:05 PM, Matt D wrote:
> 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.
> Sorry I forgot to show the error in terminal:
File "/usr/local/lib/python2.7/dist-packages/baz/op25_traffic_pane.py",
line 53, in __init__
log.write(self.data)
TypeError: expected a character buffer object
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor