Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    For the record, the site.py snippet shown for Python 3.9 is in CPython since 2013, has been mostly unchanged since then, and is still there for Python 3.11, so it seems safe to use a solution based on its behavior: github.com/python/cpython/blame/main/Lib/site.py#L467-L488 Commented Jun 1, 2022 at 9:45
  • It can also be improved to create the needed dummy entry for you on first run when there's no history file yet: if readline.get_current_history_length() == 0: readline.add_history("# history created"), as suggested in this answer Commented Jun 1, 2022 at 10:05