1👍
✅
how can I tell python that chocolate belongs to the Food class?
You don’t. the pickle file contains the data about the type of object it has pickled. It thus does not only ‘serialize" the "data", but also the "meta-data".
You should however be careful to pickle and unpickle relatively to the same type, so better in the same Python file.
Source:stackexchange.com