Skip to content

Commit 616cef5

Browse files
committed
Pickle
1 parent 9ac00bb commit 616cef5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,10 +952,11 @@ Pickle
952952
------
953953
```python
954954
>>> import pickle
955-
>>> favorite_color = {'lion': 'yellow', 'kitty': 'red'}
956-
>>> pickle.dump(favorite_color, open('data.p', 'wb'))
957-
>>> pickle.load(open('data.p', 'rb'))
958-
{'lion': 'yellow', 'kitty': 'red'}
955+
>>> P = collections.namedtuple('P', 'x y')
956+
>>> points = [P(0, 0), P(1, 1), P(2, 2)]
957+
>>> pickle.dump(points, open('points.p', 'wb'))
958+
>>> pickle.load(open('points.p', 'rb'))
959+
[P(x=0, y=0), P(x=1, y=1), P(x=2, y=2)]
959960
```
960961

961962

0 commit comments

Comments
 (0)