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

This isn't just the problem of 'duck-typing' vs 'strong typing.' There is always going to be data whose shape is very hard to define and annotate explicitly with intent of machine type checking or verification, yet much easier to describe to a programmer.

Take for example a spec for a "Set-Cookie" header syntax. It can be described as "https://tools.ietf.org/html/rfc6265#section-4.1.1", which would be a rather unwieldy thing to show, looking similarly to the pythonic polymorphic argument described in this message.

Type hinting (and strong typing) helps machines 100% of the time, and users some of the time. It's helpful if your API has an interface that is easy for a human to understand, even if you describe your data as 'a URI', "truthy" or even "Any", even if their shapes are not strictly defined.



> 'duck-typing' vs 'strong typing.'

For the n'th time, python is a strong typed AND duck typed language. Did you mean static?




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: