1

I want to know that how to get executed commands/codes history in python3.x as we are getting by history command in RHEL-8??

Tried history command and print(history) on >>>(python 3.x shell) prompt but getting error.

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> history
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    history
NameError: name 'history' is not defined
>>> 
>>> print(history)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    print(history)
NameError: name 'history' is not defined
>>> 
DjaouadNM
  • 22,013
  • 4
  • 33
  • 55
Puneet
  • 11
  • 1
  • Possible duplicate of [how do you see the entire command history in interactive python?](https://stackoverflow.com/questions/6558765/how-do-you-see-the-entire-command-history-in-interactive-python) – DjaouadNM Sep 01 '19 at 11:50
  • Getting below error:- Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> readline.get_current_history_length() Traceback (most recent call last): File "", line 1, in readline.get_current_history_length() NameError: name 'readline' is not defined >>> – Puneet Sep 01 '19 at 12:31
  • 1
    `pip install readline` (or `pip install pyreadline` if you're on Windows). – DjaouadNM Sep 01 '19 at 12:36

0 Answers0