We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 210cff8 commit 73b3d57Copy full SHA for 73b3d57
1 file changed
store-objects.md
@@ -0,0 +1,29 @@
1
+# Storing objects
2
+
3
+We can store a session objects by `shelve`. For instance:
4
5
+```python
6
+import shelve
7
8
+## Save the session
9
+with shelve.open('./my-objects', 'n') as my_shelve:
10
+ for key in dir():
11
+ if key not in ['my_shelve'] and not key.startswith('_') and type(globals()[key]) is not type(__builtins__):
12
+ try:
13
+ my_shelve[key] = globals()[key]
14
+ except Exception as err:
15
+ pass
16
+```
17
18
+To read the objects:
19
20
21
+## Read objects
22
+with shelve.open('./my-objects') as my_shelve:
23
+ for key in my_shelve:
24
25
+ globals()[key] = my_shelve[key]
26
27
+ print(err)
28
29
0 commit comments