PickleJar

PickleJar is a python module that allows you to work with multiple pickles inside a single file (I call it a “jar”)!

class picklejar.Jar(filepath, always_list=False)[source]

A file containing multiple pickle objects

Parameters
  • filepath – Path to the file

  • always_list – Ensure that Jars with single pickle return as a list

Returns

Jar object

dump(items, newjar=False, collapse=False)[source]

Write a Pickle to the file/jar.

Parameters
  • items – Item or list of items to pickle

  • newjar – Start a new jar

  • collapse – If items is a list write list as single pickle

Returns

True on file write

exists()[source]

Does the Jar exist

Returns

True or False

load(always_list=False)[source]

Loads all the pickles out of the file/jar

Parameters

always_list – Ensure that Jars with single pickle return as a list

Returns

List of de-pickled objects

Raises

IOError if jar file doesn’t exist

remove()[source]

Remove the current jar file if it exists

Returns

True

Compatibility

As of version 2.0, Picklejar is compatible with the latest versions of Python2, Python3, and PyPy!