Is there a __dunder__ method corresponding to |= (pipe equal/update) for dicts in python 3.9?

后端 未结 3 1445
故里飘歌
故里飘歌 2021-01-18 18:43

In python 3.9, dictionaries gained combine | and update |= operators. Is there a dunder/magic method which will enable this to be used for other cl

3条回答
  •  忘掉有多难
    2021-01-18 19:36

    Yes, | and |= correspond to __or__ and __ior__.

    Don't look at the python source code, look at the documentation. In particular, the data model.

    See here

    And note, this isn't specific to python 3.9.

提交回复
热议问题