[Python-3000] Help on builtin keywords

Anand Balachandran Pillai abpillai at gmail.com
Thu Mar 27 08:49:48 CET 2008


Hi,

       I recently noticed that the "help" function behaves rather
unhelpfully when one tries it on builtin keywords, as opposed
to functions.

      For example, taking the much abused "lambda", a newbie
might try to do the following to get more enlightened about lambda.

>>> help(lambda)
  File "<stdin>", line 1
    help(lambda)
               ^
SyntaxError: invalid syntax

What he gets is a very unhelpful syntax error!

Similarly for any keyword. For example, for all Python versions
before 3.0...

>>> help(exec)
  File "<stdin>", line 1
    help(exec)
            ^
SyntaxError: invalid syntax

I don't have a problem with "help" not helping out with keywords. The
problem is that it advertises itself so...

$ python3
>>> help(help)
Help on _Helper in module site:

Type help() for interactive help, or help(object) for help about object.

 So, the advertisement it gives is that it can help on any object, and
newbies to Python might interpret this as help on anything, including
keywords.

I did not check if there is a bug on this, but if the situation can be fixed
in Py3k, it would be great. I suggest that "help()" either gives a single-line
help for keywords also, or gracefully die down with a proper error string,
telling "<keyword> is a Python keyword" instead of the ugly SyntaxError.

Thanks

-- 
-Anand


More information about the Python-3000 mailing list