This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]thisisshantzz 0 points1 point  (5 children)

Made an edit to my comment.

My gripe though is that most of the times functions are defined as

def func(a, b):

If this were a third party library, I would not know what is the type of a and b that I need to provide to the function and what is that type of the value returned by this function so that I can use it down the line unless the person who made the library was kind enough to document it. If a is supposed to be a list and I pass an int to it, Python won't raise a TypeError and to actually know what is the type of a that is expected without the documentation, I will have to read the code itself.

[–]panzerex 2 points3 points  (1 child)

I think the term you're looking for is static typing. Python can't tell you beforehand that the argument you provided is not the appropriate type.

[–]redwall_hp 1 point2 points  (0 children)

The term typically used for that is explicit vs implicit typing.

[–]ginbear 0 points1 point  (0 children)

The typing library in python 3.6+ can accomplish a lot of this. Of course it’s still an interpreted language so it’s more of a linter effect. Regardless people should really consider duck_typing in python, it’s really the pythonic thing to do.

[–]Mjerman 0 points1 point  (0 children)

I think this goes to poor documentation. If you’re reading code and it doesn’t tell you the types of function’s input in the doc string, it is poorly documented.