Menu Close

How to save a Python interactive session?

Sometimes, we want to save a Python interactive session.

In this article, we’ll look at how to save a Python interactive session.

How to save a Python interactive session?

To save a Python interactive session, we can use the readline module.

For instance, we write

import readline

readline.write_history_file('/home/ahj/history')

to call readline.write_history_file to save the interactive session content into the /home/ahj/history file.

Conclusion

To save a Python interactive session, we can use the readline module.

Posted in Python, Python Answers