[Python-Dev] readline.clear_history()

Guido van Rossum guido at python.org
Wed Aug 27 15:45:44 EDT 2003


> I've been working on a set of Python tools that use readline, but want to 
> keep history separate between different interaction modes.  Unfortunately, 
> this really needs to be able to access readline's clear_history(), as 
> read_history_file() leaves existing history intact.

Sounds like a good feature.

> I'd be happy to whip up a patch to add this (as readline.clear_history()), 
> but I was wondering if perhaps the reason it's not currently exported by 
> the readline module is a compatibility issue for older readline 
> implementations that are officially supported.  Thanks.

It's probably laziness.  When I created the initial readline module, I
didn't know anything about the C API of GNU readline.  All I wanted
was basic readline functionality, and I applied the YAGNI principle
vigorously.  Gradually, various people have added APIs for various
useful GNU readline APIs.

But there might be a version issue as well.  I have various versions
of the readline sources online just for this purpose (GNU readline is
notorious for not providing an easy way to check at compile-time which
version you are using), and I note that clear_history() is present in
2.2, but not in 2.0.  I seem to recall that 2.2 is the oldest widely
used version, so I think you're safe.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list