Python Forum
functions/methods - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: functions/methods (/thread-35138.html)



functions/methods - menator01 - Oct-02-2021

In some of the code I have seen def somefunc() -> list: or varient. What does that do?


RE: functions/methods - Yoriz - Oct-02-2021

https://docs.python.org/3/glossary.html#term-type-hint Wrote:type hint
An annotation that specifies the expected type for a variable, a class attribute, or a function parameter or return value.

Type hints are optional and are not enforced by Python but they are useful to static type analysis tools, and aid IDEs with code completion and refactoring.

Type hints of global variables, class attributes, and functions, but not local variables, can be accessed using typing.get_type_hints().

See typing and PEP 484, which describe this functionality.



RE: functions/methods - menator01 - Oct-02-2021

Thank you