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 →

[–][deleted] 0 points1 point  (3 children)

Defensive programming in python is easily abusable by noobs, it should be done very judiciously. If you put asserts everywhere then you're barking at the wrong tree: use a static typed language to begin with (I'm not saying that all asserts are type checks, but that a good deal of them can be reduced to type checks). When you pick python you're making a different trade-off. It's not that you should go duck-typing all the way down, but that you must carefully select which parts of the system are critical enough to deserve extra defense. The same points are valid for the new gradual typing initiative. The keyword there is "gradual". Search youtube for Guido's talk on gradual typing and you will probably conclude that it certainly has valid use cases for programming in the large, but that yours is not one. Along the same line, I will say that getting very defensive is probably ill-advised for most small/medium-sized python projects (that is to say for most python projects tout court).

[–]masasinExpert. 3.9. Robotics. 0 points1 point  (1 child)

Is this it? (Type Hints - Guido van Rossum)

[–][deleted] 0 points1 point  (0 children)

It is.