[Python-ideas] Help mode improvement.

Mike Meyer mwm at mired.org
Tue Oct 11 06:06:04 CEST 2011


On Tue, 11 Oct 2011 12:39:31 +1100
Steven D'Aprano <steve at pearwood.info> wrote:
> Stayvoid wrote:
> > Hi there!
> > 
> > I want to make an improvement connected with the interactive help mode.
> > 
> > Example:
> > You want to check some keys in the dictionary, but you can't remember
> > the syntax of the command.
> >
> > If you type something like this: help(key), the interpreter will
> > output an error. Because help(key) is just a plain
> > expression, and it tries to evaluate key first before even calling
> > help(). Maybe help(*key*) could make it work?
>  >>> help('key')
> no Python documentation found for 'key'
> 
>  >>>
> 
> Perhaps help should be more aggressive at trying to find something 
> useful before giving up. 

Having help do a search if passed a string would qualify as "more
aggressive", would be useful, and wouldn't break existing usage.  It
should be easy to tweak the help function so that if it's passed an
instance of a basic_string, it compiles that into a regular expression
and uses that to try and find things.

The question is - what should it be searching? top-level names in
sys.modules? Docstrings in sys.modules? Something else entirely? Is
there anything that can be searched here that would both be more
useful than the existing interactive facility and not take an
inordinate amount of time to search?

     <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Python-ideas mailing list