Cool feature about Spyder

ruben.ciranni (4650 points)
7 13 31
asked Oct 29, 2021 in Programming in Python by ruben.ciranni (4,650 points)
recategorized Oct 30, 2021 by andrea.sterbini
I just found out a cool feature of Spyder and I wanted to share it:

When defining a function you can automatically generate a description of that function by specifying the types of the parameters and of the return value (For example ex(a: int, b: list) -> bool) and pressing enter twice.

That is really useful to always have under control the what the parameters and the returns of each function represent.

3 Answers

gabrimat (5630 points)
2 2 25
answered Oct 29, 2021 by gabrimat (5,630 points)
Thank you for sharing
Luigi Pizza (6120 points)
11 20 65
answered Oct 29, 2021 by Luigi Pizza (6,120 points)
Yes, but they are just a suggestion: Python will not check if a is an int or if b is a list, it is just to make the code easier to read.
ruben.ciranni (4650 points)
7 13 31
commented Oct 29, 2021 by ruben.ciranni (4,650 points)
Yes, it only generates a docstring which describes the function
KilianS (3590 points)
5 9 27
answered Oct 30, 2021 by KilianS (3,590 points)
i also thank you for sharing !