[Tutor] Need help printing a pickled data

Matt D md123 at nycap.rr.com
Tue Jun 25 21:45:03 CEST 2013


> 
> The real question is why do you want this pickle in a file?  I am not sure 
> it will be easy to pull out and reuse anyway. Given your experience level, 
> I think this is a lot of work for something that you are unlikely to be able 
> to easily use. I think it would be more useful to `log.write(repr(attrs))`.
> 
> Once you have the bytes of pickled data, just write that to file.
> 
> with open('mypicklelog.txt','ab') as log: 
> # All pickles will run together because there is no spacing.
>     log.write(self.data.to_string()) 
> 
> 
> Again, I think you would be better off with the repr()
> with open('mypicklelog.txt','ab') as log: 
>     log.write(repr(pickle.loads(self.data.to_string())))
> 
> 

OK thanks.  what i did is went back to the old logger where everything
was working.  and then i put

        self.update(attrs)
        with open('mypicklelog.txt','ab') as log:
            log.write(repr(attrs))

to try to lay eyes on the pickle.  What i really need is a way to test
this GUI without waiting so long.  I was thinking if i could get a hold
of one of the c++ maps i could make a small program that would enable me
to send it to the python gui at will; to test the gui.

I am not sure if there is a way around this testing difficulty because
two of the TextCtrl fields are empty.  This is because currently the c++
is only sending in the container the contents of the Header Data Unit
(HDU).  In digital radio the transmission consists of frames, the HDU is
one of them, as the name suggest it is the first.  But the Logical Data
Unit 1 (LDU1) contains the source and destination id data that
ultimately i need to get in the UI.  So I am going to have to get into
the c++ map stuff and get familiar with how this pickle process works
anyway. This is pass/fail thing, it doesn't matter if my code is 'ugly'
or whatever and I have time so it shouldn't be impossible.


More information about the Tutor mailing list