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,910 points
3,836 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,300 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
786 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
• 69,220 points
1,144 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, 2019 in Python by Neel
• 3,020 points
1,070 views
+1 vote
1 answer

Error in git and python command

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

answered Jul 4, 2019 in Python by Simran
1,218 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer
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,300 points
685 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,300 points
2,366 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP