Why is it possible to store a str value on a int type variable on Python using typing [duplicate]

This question already has an answer here:

Is Python strongly typed?

10 answers

What are Type hints in Python 3.5

3 answers

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)) #

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...

Read More »

By: StackOverFlow - 5 days ago

Related Posts