Python 2.7: no documentation found when typing help('print')
Solution 1
This looks like a bug of Python 2 as something like help("dir")
works properly. It probably does not work because print
is a special keyword, unlike Python 3. Stick to Python 3 or run the following command instead of help("print")
:
help("__builtin__.print")
Solution 2
That documentation is always installed , because it is embedded on the source files. The specified command does not work because in python2.7 print
is both a statement and a function, so it may be confusing the help
function.
If you use, for example help('os')
or help("if")
you should get the correct information:
$ python -c "help('if')"
The ``if`` statement
********************
The ``if`` statement is used for conditional execution:
if_stmt ::= "if" expression ":" suite
( "elif" expression ":" suite )*
["else" ":" suite]
It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section *Boolean operations*
for the definition of true and false); then that suite is executed
(and no other part of the ``if`` statement is executed or evaluated).
If all expressions are false, the suite of the ``else`` clause, if
present, is executed.
So the documentation is installed and that behavior you see should be a bug.
Related videos on Youtube
lucacerone
Updated on September 18, 2022Comments
-
lucacerone over 1 year
I have just installed Python 2.7 and Python 3.2 on my Ubuntu 12.04 (32 bit).
sudo apt-get install python python-doc python3 python3-doc
I opened a Python 3 shell (is it called like that) typing
python3
from a terminal. If I issue the commandhelp('print')
everything works fine and I can read the documentation.However if I open a Python 2.7 shell (
python
from a terminal) when I typehelp('print')
I get the following message:no documentation found for 'print'
How can I get to use the documentation in Python 2.7 as well?