I think what is meant is Union[List[TemperatureMeasurement], List[HumidityMeasurement]], , so a list of either just TemperatureMeasurements or a list of only HumidityMeasurements.
> you care only about the behaviour ... not the explicit type of that input
"duck typing" is a run-time equivalent of structural typing. It would be a little more accurate to say the value's properties (ie., the object behaviour) *is* the type.
A "protocol" isnt a means of "ignoring the real type, ie., the name we give a type". It is a means of expressing a structural type. Nominal typing, ie., a type "being some name" isn't fundamental.
Indeed, my biggest complaint with python's static typing efforts are how hamfisted nominal typing has been shoved on top of python, as-if it were just "failing to be java".
This is the best way I've seen my feelings on this summarized. Thanks! I really find that efforts to bring nominal typing to Python really just restrict it, and it becomes not the same language anymore. If I want that kind of typing, I prefer to use a language that does it properly. Otherwise, I want a type system that works for how Python is designed.
I'm really finding these days that I have to restrict the range of types my functions are designed to work on just to satisfy a bunch of linters. It's very annoying. And imho goes against the grain of why I chose Python in the first place.
Guido wanted to create a procedural imperative language that used runtime tricks to look simple. What he actually created was a highly (ad-hoc) polymorphic language with extraordinary power.
Since realising this guido has gone about doing everything to hobble efforts to realise the underlying efficacy of the python model -- and shove it back into the procedural box he had intended it to be in.
Given python3, this appears to be a remarkable contradiction. Python2 was what guido wanted, when python3 came along and "software engineers" won over "educators", playing the "lets keep it dumb and procedural" game was conclusively dead.
I have a lot of respect for Guido's vision, but this approach to typing has frustrated me. It feels like he's fighting a proxy-war on procedural-python, using the type system to force the rest of us to concede.