python auto type

Solutions on MaxInterview for python auto type by the best coders in the world

showing results for - "python auto type"
Rafael
13 Sep 2020
1# Unlike in C/C++ or any statically-typed language,
2# the typing in python is dynamic, which means that
3# Python will figure out himself wich type should be
4# use for your value.
5# In Python, you can also change the type of a
6# variable during ewxecution, but I strongly advise
7# against  doing that.
8
9"""define a type in C++"""
10# int x;
11"""auto type in C++"""
12# auto x = 5;  // C++ will automatically define AnIntegerWithAutoType as int
13
14"""static type in Python"""
15x: int
16"""auto type in Python"""
17x = 5
18
19# You can also define a python variable without giving it a value.
20
21from typing import Any
22x: Any # This means that x will not have a value but can get a value from any type later