3 ms·
Type hints are optional, why not just not use them? How are you going to know the type of an object that gets passed to a function? Why is it better to go arou
by StavrosK 8y ago
Type hints are optional, why not just not use them?
How are you going to know the type of an object that gets passed to a function? Why is it better to go around the codebase looking for things instead of glancing at the function signature?
- antt 8y agoThe type (class really) of an object tells you nothing about how it will behave. What you need to do is check the methods attached to the object, not class, at runtime: 1) Exist. 2) Behave how you want them to behave. I've written plenty of code that got that done by using an assert just after the docstring. People will monkey patch, if not in your code base, than in a library you're importing.