I know my question might be confusing, it's hard to ask something you don't know what it is exactly (I'm going to call it 'hint'), so my apologies for that. Having that said, here it is what I mean (the text in the white box):
My questions are:
- How can I make my own hint (and customize it) text when calling a function?
- What is it exactly?
- What does the text in this example mean?
You are in fact correct about the textbox being called hint, so no quotation needed. What you are seeing is a type hint. It is supported by the
typing
module inside Python. Refer to the example below:Then when you try to call the function you will see a textbox very similar to the one you showed. I encourage you to read the
typing
module page if you want to learn more about it.That said, in most cases you will not be needing that type hint because doc strings ("""info about my function""") are usually sought after more.
IDLE calls the popup a 'calltip'. For a module defined in python code with a def statement, it shows the signature on the first line and the first line of the doc string on the second. They are intended to work correctly for any type of callable invoked with parentheses.
If you type '(' the box pops up unless you are typing fast. After it closes, to bring it back, you position the cursor between '(' and ')' and either select Edit on the top menu and 'Show call tip', or type the shortcut key shown on the menu. For more, see the doc.
For future reference:
First, there are 2 types of 'hints' as I called them:
And the one introduced in Python 3.0:
With what is written above and what Terry Jan Reedy answered:
Sadly, because I'm not working on with what I was at the moment and I never had the need to understand it, I have not found what the syntax for each calltip is.