[Python-ideas] Dict joining using + and +=

Inada Naoki songofacandy at gmail.com
Tue Mar 5 04:56:49 EST 2019


On Tue, Mar 5, 2019 at 6:42 PM Jimmy Girardet <ijkl at netc.fr> wrote:
>
> Indeed the "obscure" argument should be thrown away.
>
> The `|` operator in sets seems to be evident for every one on this list
> but I would be curious to know how many people first got a TypeError
> doing set1 + set2 and then found set1 | set2 in the doc.
>
> Except for math geek the `|` is always something obscure.
>

Interesting point.

In Japan, we learn set in high school, not in university.  And I think
it's good idea that people using `set` type learn about `set` in math.
So I don't think "union" is not only for math geeks.

But we use "A ∪ B" in math.  `|` is borrowed from "bitwise OR" in C.
And "bitwise" operators are for "geeks".

Although I'm not in favor of adding `+` to set, it will be worth enough to
add `+` to set too if it is added to dict for consistency.

FWIW, Scala uses `++` for join all containers.
Kotlin uses `+` for join all containers.
(ref https://discuss.python.org/t/pep-584-survey-of-other-languages-operator-overload/977)

Regards,

-- 
Inada Naoki  <songofacandy at gmail.com>


More information about the Python-ideas mailing list