3 ms·
I'm not questioning that python api isn't clear. Neither is clojure one. Both require the user to read them in order to properly apply them. I think pythons re
by blain_the_train 10y ago
I'm not questioning that python api isn't clear. Neither is clojure one. Both require the user to read them in order to properly apply them.
I think pythons resolutes only seem less surprising because someone would be used to them? Maybe that coercion is easier to reason about. Im honestly not sure. Like this example:
In [19]: s = set([1, 2, 3])
In [20]: s.union({"x", "y"})
Out[20]: {1, 2, 3, 'y', 'x'}
Is that more clear then explicitly requiring only sets be unioned?
Why the key and the value? The meaning of the key and value have been drastically change now. Maybe this is what all languages do?
anyway, I think i gained a lot thinking this through. Thanks everyone :)
*One error Is I mistakenly said that strings weren't hashable.
- todd8 10y agoOh, I think I understand your question. This is a set literal, not a map literal: {"a", "b", "c"} This is a map: {"name": "Fido", "age": 8} Note the colons. The point I was making is that Python doesn't make performance trade offs with these set APIs. Set union is in no way surprising. It either gives the correct intuitive result or raises an exception because of incorrect argument types.
- blain_the_train 10y agoI'm having quite the day. I think switching between clojure and python is frying my circuit. I know the difference between a map syntax and set and somehow managed to use set in place of map. I think this happened in part because my point is that any output of union(set, dict) is up to the language designer and has no basis in set theory (though i would be interested to here other wise) >>> s = set([1, 2]) >>> d = dict(x="hi") >>> s.union(d) set([1, 2, 'x']) apologies for the confusion... I need to proof read my comments more throughly.