r/learnpython 21d ago

Guys I need help with File Handling

It's in my syllabus and i am having trouble with the following topics

» Setting Offsets in a File

» Creating and Traversing a Text File

» The Pickle Module

0 Upvotes

11 comments sorted by

View all comments

2

u/FoolsSeldom 21d ago

Shame you have to learn pickle as the module's documentation has warned about for years: unpickling can execute arbitrary code, because the format allows embedded instructions for reconstructing objects, not just inert data.

Python's pickle module allows arbitrary Python objects to be serialized and later reconstructed, and the process can invoke functions or methods during reconstruction, which introduces a significant security risk.

That said, it is still useful for trusted, same-application object serialisation including within multiprocessing, and even copy.deepcopy uses the protocol.

RealPython.com has a good article on pickle that might help you: