Command history in interactive Python

0 votes
While using the default python interpreter on Mac OS X, I have cleared all my previous commands using Cmd+K. I can find them one by one with the help of arrow keys but how do I see all the commands that I have entered? Is there any such option like the --history option in bash shell.
Nov 27, 2018 in Python by ana1504.k
• 7,890 points
231 views

1 answer to this question.

0 votes
You can use the following to get the length:

readline.get_current_history_length()

and the following to view each command:

readline.get_history_item()
answered Nov 27, 2018 by SDeb
• 13,190 points

Related Questions In Python

0 votes
1 answer

Call a shell command in Python?

Try this - os.system("commands and arguments") READ MORE

answered Jun 21, 2018 in Python by Hamartia's Mask
• 1,580 points
31 views
0 votes
2 answers

Calling an external command in Python

import os os.system('external_command') Replace external_command in the above code ...READ MORE

answered Oct 16, 2018 in Python by Omkar
• 67,660 points
47 views
0 votes
1 answer

Is it possible to run a function in Python using the command line?

Suppose your file name is demo.py and ...READ MORE

answered Jun 26 in Python by Neel
• 3,010 points
58 views
+1 vote
1 answer

Error in git and python command

The answer to your first problem is ...READ MORE

answered Jul 4 in Python by Simran
28 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 349 views
0 votes
1 answer

External command in Python

you can check the subprocess module in ...READ MORE

answered Oct 1, 2018 in Python by SDeb
• 13,190 points
30 views
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,190 points
313 views