0

I come from a java background and i'm starting with python 3.x and types. In java it's not possible to do something like this:

num:int = 5;
name:str = num
num = "hola"

print(type(num)) # <class 'int'> 

The interpreter doesn't complain when storing an int value in a str variable or viceversa.

I didn't find any example of using this var_name: type_name = 5 kind of asignations in python's official 3.6.7 docs, but, again, the interpreter think it's ok.

Why is this possible?

Dawood ibn Kareem
  • 77,785
  • 15
  • 98
  • 110
Hernan
  • 1,149
  • 1
  • 11
  • 29

0 Answers0