My IDLE (Python 3.4.3) won't show functions doc-strings when typing the name of the function.
Is anybody familiar with this problem?
I've tried everything, including uninstall etc. Answers on the web are nowhere to be found.
I'm talking about showing the docstrings automatically, NOT when specifically typing :
print(func. __ doc __)
Thanks
Docstrings, are part of calltips, not completions. Calltips are shown when one types '(' after the name of an acccessible function. The calltip should stay displayed until one types ')' or clicks the mouse or otherwise moves the cursor to dismiss it. Cntl-\ brings it back.
A calltip consists of the function signature and the first line of the docstring. For builtins without an accessible signature (such as, in 3.4.3, int or bytes), the calltip consists of all lines up the fifth line or the first blank line.
The set of accessible functions depends on what modules have been imported into the user process (where your code is executed), including those imported by Idle itself, and what code has been run (since the last restart). For example, restart the Shell (Cntl-F6), open a new editor window, and enter
itertools.count(
A calltip appears because Idle imports itertools into the user process for its own use. Enter
turtle.write(
and nothing appears, because the Idle does not import turtle. Cntl-\ does nothing either. Entering
import turtle
above the function call does not immediately help, but if one runs the file to perform the import, calltips for turtle functions become available.
This suggests that one might want to run a file after writing the import statements at the top, or immediately run an existing file before editing.
Comments:
I suspect your problem is that you are trying to get a calltip for a function that is not currently accessible, even though it might have been accessible before and will become accessible after running your code.
I have opened issue 24028 to add something like the above to the Idle docs as a subsection on calltips after the subsection on completions
Existing issue 1350 is about adding the option to display the full docstring.
The availability issue is a nuisance. I have a couple of ideas for improving it. In the meanwhile, use the suggestion above about running your imports.
EDIT: 2018 Aug 2
Some combinations of Mac OSX or MacOS and tcl/tk require an addition of one line to idlelib/calltip_w.py (3.6+) or idlelib/CallTipWindow.py (3.5-). Issue 34275
self.label.pack() # Line 74
tw.update_idletasks() # ADD THIS LINE!
tw.lift()
This should be included in future releases. If the above does not work, please remove _idletasks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With