[Tutor] Need help printing a pickled data
Matt D
md123 at nycap.rr.com
Tue Jun 25 18:32:46 CEST 2013
>
> with open('mypicklelog.txt','ab') as log: # open in binary mode
> pickle.dump(self.data, log) # serialize data and write to file
>
> where pickle.dump(obj, file) converts `obj` to a sequence of bytes before it
> is written to `file`.
>
I put this like this:
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','ab') as log: # open in binary mode
pickle.dump(self.data, log) # serialize data and write to file
And I still get nothing. This has me super confused, I have trying at
this for a long time and I have been reading the docs like
http://docs.python.org/2/library/pickle.html
And I still don't get it to work. So the C++ makes the pickle, this is
from the comments in the C++ :
/**
* snapshot_du_handler. Writes traffic snapshots to a msg_queue based
* on the HDU frame contents. The format used is that of a pickled
* python dictionary allowing the other end of the queue to pick only
* those fields of interest and ignore the rest.
*/
Then the python program (attached) program unpickles and repickles it?
I attached the python program, if you have a minute or two please take a
look, its not too long.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: op25_traffic_pane.py
Type: text/x-python
Size: 9405 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20130625/1b3877cd/attachment-0001.py>
More information about the Tutor
mailing list