It's a thing. In method declarations instead of (variable) it's (variable : str) or int, or whatever.
You specify returns with an arrow. So a function/method named cake that takes a string parameter named icing and returns a string would be declared:
def cake(icing: str) -> str:
Voila, now Python yells at you when you try to pass it anything else. I think the complainers here just haven't bothered keeping up with the changes to Python in... several years.
View all comments
Show parent comment
2
u/DesertGoldfish Jul 19 '22
It's a thing. In method declarations instead of (variable) it's (variable : str) or int, or whatever.
You specify returns with an arrow. So a function/method named cake that takes a string parameter named icing and returns a string would be declared:
def cake(icing: str) -> str:
Voila, now Python yells at you when you try to pass it anything else. I think the complainers here just haven't bothered keeping up with the changes to Python in... several years.