Is there a way to view cPickle or Pickle file contents without loading Python in Windows?

TimY picture TimY · Nov 26, 2012 · Viewed 36.9k times · Source

I use cPickle to save data sets from each run of a program. Since I sometimes need to see the outline of the data without running the code, I would like an easy way to quickly view the contents by just double-clicking on the file. I am trying to avoid having to load a terminal and pointing python to a file each time, just to run some print script.

I looked for Notepad++ plugins but couldn't find anything.

Is there some easy way to do this? Does anyone have any suggestions?

Note: I run Windows 7.

Answer

nth picture nth · Dec 24, 2016

For Python 3.2+/2.7+ you can view (__repr__'s of) pickles from the command-line:

$ python -c "import pickle; pickle.dump({'hello': 'world'}, open('obj.dat', 'wb'))"
$ python -mpickle obj.dat
{'hello': 'world'}

It should be easy to integrate this into the Windows shell.