[Tutor] Need help printing a pickled data
Matt D
md123 at nycap.rr.com
Wed Jun 26 03:32:44 CEST 2013
>
> I still think it is silly to write pickled data to a log. Logs are for
> human-readable information, not arbitrary data. Even with text-mode
> pickle, it's still junk:
>
> py> import pickle
> py> data = {'a': None, 'b': 42}
> py> pickle.dumps(data, 0)
> "(dp0\nS'a'\np1\nNsS'b'\np2\nI42\ns."
>
>
> Why do you want to see rubbish like that inside your log file? Surely
> something like this is better?
>
> log.write("data = %r" % data)
>
> which will give you a line like this:
>
> data = {'a': None, 'b': 42}
>
>
> in your log, which is a million times more understandable than a pickle.
>
>
Yes the later would be better for my eyes to see whats going on there,
and that is necessary for me. But I also want something that will
mimic, or a copy of, what the UI is currently receiving not to look at,
but to have, at a later time, the program open, or send to the program
with another program, in order to test the functionality of the UI.
More information about the Tutor
mailing list