0

I have python 2.7.8 command Line, and every time I exit it, I lose my progress. Is there a way to save it or make files on the comand line?

agf
  • 171,228
  • 44
  • 289
  • 238

1 Answers1

0

Check IPython and IPython notebook. Use IPython and save what you did to a python script file , say foo.py, by %save command:

%save 'foo' n1-n2 n3-n4 ... 

where n1-n2, ... are line number of beginning and end to save. To resume your work, run the file in ipython:

%run foo.py

Then, all variables in the script are accessible and you can proceed from that point.

In case of you want save your code with documentation, IPython notebook is a perfect fit. In a web browser, you run your codes. Then, it saves history of your codes and their outputs in a session. So you can resume your work from the session. It is also very readable and you can export your work in HTML, PDF, and so on.

Jihun
  • 1,415
  • 1
  • 12
  • 16
  • Thank you. Am I able to publish my games and apps that I code on Ipython notebook and IPython? – Ben Schwartz Nov 02 '14 at 21:49
  • For games and apps, you'd better to ***serialize*** python objects to save, and write them into files. Pickle is widely used for the serialization. – Jihun Nov 03 '14 at 02:32