3 ms·
> Couldn't they use helper methods to convert all those types he brought up to a single common type that they annotated with? But then it wouldn't be "pythonic
by snuxoll 11y ago
> Couldn't they use helper methods to convert all those types he brought up to a single common type that they annotated with?
But then it wouldn't be "pythonic". To be frank though, I think being too generous with your inputs is just asking for maintenance hell. I don't see why requests feels the need to allow data in so many different formats when one or two + conversion functions for anything else would be sufficient.
- seivan 11y agoI've come to realize it's an addiction/urge, that's the only /reasonable/ answer I can give.
- seanp2k2 11y agohttps://en.m.wikipedia.org/wiki/Robustness_principle https://en.m.wikipedia.org/wiki/Robustness_principle """ Be conservative in what you do, be liberal in what you accept from others (often reworded as "Be conservative in what you send, be liberal in what you accept"). """
- taneq 11y agoDidn't we decide later that that's a bad idea? I mean, in the early days of the web, Internet Explorer was the very embodiment of this principle and a couple of decades later the internet is still full of the resulting non-standard crud.
- lomnakkus 11y agoYes we did. It can also lead to really surprising security issues in protocol-land where such "liberalism" interacts badly with security-sensitive portions of protocols. (Security is non-trivial and mostly there are very good reasons that things are exactly as they are in such protocols.)
- taneq 11y agoIn my (limited) Python experience, this kind of amorphous-blob-of-properties interface is great fun to write but is absolute hell to decipher later, especially if you're not the person who wrote it. You end up having to read the entire function and usually recurse through most of the things it calls in order to even know how to call it. That's maybe not so much of an issue if you're just writing small self-contained scripts, but an interface to an API it's awful.