#!/usr/bin/env python # Typical usage: pickinsp.py latest.mdf.pickle import cPickle,sys #try to get a name of the pickle file from the command line: try: filename=sys.argv[1] except: filename=None print "filename was not entered from command line" filename=raw_input("enter filename=>") if filename=="": filename="latest.mdf.pickle" #default #try to open that file: try: inf=open(filename,'r') print "opened",filename except: print "trouble opening",filename sys.exit() #try to load the dictionary (notice I do not use try/except here) h=cPickle.load(inf) print "\n loaded an object with type:",type(h)," (hopefully a 'dict')" print "\n try printing all the keys:" allkeys=h.keys() print allkeys firstkey=allkeys[0] print "\n try printing the value for ",firstkey," in the dictionary:" print h[firstkey] print "\n did you see 'NEWI' in the above?"