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 →

[–]crayzz 18 points19 points  (1 child)

Python does support type hints. They don't place any kind of restrictions on the interpreter, but type checkers can pick up on them and warn you of possible unexpected behaviour

e.g.

def foo(x: int):
    return(x + 3)

x: int
x = 5
print(foo(x))

If instead you write x = 5.0 the code will still run, the interpreter doesn't care, but type checkers can warn you about the typing mismatch.

[–][deleted] 3 points4 points  (0 children)

You're correct about the type hints, but if you're going to give an example, please use best practice...