Suppose you run a code block in script_mode and produce the following data:
my_data = [1, 2, 3, 4]
Now I switch to console work to debug the code. I need to use the data created now, and not copy directly to avoid the gibberish effect. My solution is to sort first in script_mode and sprinkle it in interactive_mode:
Codes with 5 commands:
Script Mode
import pickle
with open('my_data','wb') as file:
pickle.dump(my_data, file)
Interactive_mode:
import os, pickle
os.chdir('~\..\')
with open('my_data', 'rb') as file:
my_data = pickle.load(file)
How to do it in fewer steps?
source
share