3 ms·
> We enforce the calling convention with code in our library that looks like this: if not isinstance(val, str): raise ValidationException('value must b
by keypusher 14y ago
> We enforce the calling convention with code in our library that looks like this:
if not isinstance(val, str):
raise ValidationException('value must be str', val)
I love Python, but the more I used it the more I come to see dynamic typing as a mistake. On large projects with shared library code and deeply nested calls, one of the most pervasive problems seems to be wrongly typed data. And building validation exceptions into all of your code seems like a poor solution.
- __alexs 14y agoThey could have implemented it using a simple decorator for non var-args methods which personally I think is more attractive. Obviously you still pay the cost at run-time but at least the actual source looks more sensible that way.