Explicitly declaring a variable type in Python

As of Python 3, you can explicitly declare variables by type:

x: int = 3

or:

def f(x: int):
    return x

Python has no type declarations. Python 3 introduces something called function annotations, which Guido sometimes refers to as "the thing that isn't type declarations," because the most obvious use of it will be to provide type information as a hint.

As others have mentioned, various IDEs do a better or worse job at auto-completing.


in case you want methods callable on a type ...you can always use dir(var) in python console...