def fnpickle(object, fileorname, usecPickle=True, protocol=None, append=False):
 if (usecPickle and six.PY2):
  import cPickle as pickle
 else:
  import pickle
 if (protocol is None):
  protocol = pickle.HIGHEST_PROTOCOL
 if isinstance(fileorname, six.string_types):
  f = open(fileorname, (u'ab' if append else u'wb'))
  close = True
 else:
  f = fileorname
  close = False
 try:
  pickle.dump(object, f, protocol=protocol)
 finally:
  if close:
   f.close()

def fnpickle ( object , fileorname , usecPickle = True , protocol = None , append = False ) : if ( usecPickle and six . PY2 ) : import cPickle as pickle else : import pickle if ( protocol is None ) : protocol = pickle . HIGHEST_PROTOCOL if isinstance ( fileorname , six . string_types ) : f = open ( fileorname , ( u'ab' if append else u'wb' ) ) close = True else : f = fileorname close = False try : pickle . dump ( object , f , protocol = protocol ) finally : if close : f . close ( )
pickle an object to a specified file .