Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The pythonic way is to do duck typing, meaning don't check the params types at all. Assertions are ok to check things that should never happen. But if you're gonna put them everywhere then better use type hints. I'd use TypeError on public APIs, for private APIs is as bad/good as assert.


What I describe is duck typing, with eager authentication of duck specie. Exceptions raised at point where the greatest clarity of error message is possible.

Aspirationally, anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: