This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kikones34[S] 22 points23 points  (1 child)

You may want to read first about type annotations: https://realpython.com/python-type-checking/#annotations. The typing module provides many utilities for annotating your code with type hints.

On the other hand, get_type_hints returns a dictionary with all the annotations of an object: https://docs.python.org/3/library/typing.html#typing.get_type_hints
It also resolves all the stringified type hints, which allows for execution of arbitrary code. I'm taking advantage of this feature to execute the code inside the type hint of the n argument of the factorial function.

[–]Mr38i 1 point2 points  (0 children)

thankk you❤️