https://github.com/kentwait/picklenote
Pickle an object together with a short note about it
https://github.com/kentwait/picklenote
Last synced: 3 months ago
JSON representation
Pickle an object together with a short note about it
- Host: GitHub
- URL: https://github.com/kentwait/picklenote
- Owner: kentwait
- License: mit
- Created: 2020-06-05T05:19:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-05T06:35:04.000Z (about 6 years ago)
- Last Synced: 2025-12-15T09:17:07.625Z (6 months ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# picklenote
Pickle an object together with a short note about it
## Quickstart
```python
import picklenote as pkl
data = [0, 1, 2, 3, 4]
note = "A list of 5 integers from 0"
# Dumps the object `data`, the annotation about the object `note`, and the filename where to save the pickle
pkl.dump(data, note, 'int_list.pickle')
# Loads the pickle as a PickleNote object with `.obj` and `.note` attributes
annotated_data = pkl.load('int_list.pickle')
# Returns the pickled object `[0, 1, 2, 3, 4]`
annotated_data.obj
# Returns the note:
# A list of 5 integers from 0
annotated_data.note
# Can also be loaded using regular pickle
# Loads as a dictionary `{'obj': ..., 'note': ...}
import pickle
picklenote_dict = pickle.load(open('int_list.pickle', 'wb'))
```