DEV Community

Discussion on: Using Python's Type Annotations

Collapse
 
yucer profile image
yucer

The problem with statically-typed languages is that you tend to spend an enormous amount of time finding out what type of variable you've used somewhere in your code.

Why would you do that ? Given that is statically-typed language the compiler and the editor have the info of the variable type in the moment that you are programming.

They can not do that in a dynamically-typed language without stuff like the one described in this article, or something like the method documentations.

By the way, we can think about this like another way to document the method parameters and result.

I guess it is like this:

  1. statically-typed language: You spent more time selecting the types to define / choose in every context.

  2. dynamically-typed language: You spent more time guessing the types when you are using it.

Take this example:

You are going to use a python function called compute for the first time.

def compute(foo, bar):
   # .... 20 lines here

If the method has no documentation string, you need to read the documentation or read the code to infer the type.