I'm trying to turn off Python's/IDLE's history feature in the same way that I can do it for bash by running bash --init-file <( echo ". ~/.bashrc; unset HISTFILE" ). To do this, I've tried running PYTHONHISTORY=/dev/null python3 and export PYTHONHISTORY=/dev/null; python3. In both cases I confirm by way of os.environ["PYTHONHISTORY"] that Python's PYTHONHISTORY environment variable is set to /dev/null, but it is still reading the normal history file and saving commands to it. Why is it not working? How do I make it work? Is there some kind of --no-history switch that can passed to the Python interpreter as a command line option that'll do it?

Melab's user avatar

2

documentation shows that it has to be PYTHON_HISTORY and it was added in Python 3.13. And /dev/null works for me when I use Python 3.13 but it doesn't work when I use Python 3.12

2026-03-06 00:35:05 +00:00

Commented 7 hours ago

I also can't find PYTHONHISTORY in documentation for any older version.

2026-03-06 00:43:09 +00:00

Commented 7 hours ago

The var for disabling history or changing the file location is PYTHON_HISTORY not PYTHONHISTORY. Note that this feature was added relatively recently (merged in 2024 #13208) and is only available in Python >= 3.13.

wim's user avatar

Sign up to request clarification or add additional context in comments.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.