[Tutor] newbie intro to pickle
Tony Meyer
tameyer at ihug.co.nz
Sat Apr 16 02:03:11 CEST 2005
> Does anyone know if there are some *beginner*-user-friendly tutorials
> out there for pickle? Or can give a sample of how you would implement
> it into a VERY SIMPLE program? Obviously I can get to the "import
> pickle" step, but once I'm past that, I'm totally lost!
There's the example in the documentation:
<http://docs.python.org/lib/pickle-example.html>
But to put it really simply, you can just use it like this:
>>> import pickle
>>> my_list = [4,5,6,6]
>>> pickle.dump(my_list, file("temp.pik", "w"))
(restart Python here to show that it works across sessions)
>>> import pickle
>>> my_list_reloaded = pickle.load(file("temp.pik"))
>>> my_list_reloaded
[4, 5, 6, 6]
=Tony.Meyer
More information about the Tutor
mailing list