Skip to content

operator.rst mentioning or_ should also mention dict merge operators #141623

@doronbehar

Description

@doronbehar

I was designing the following:

from functools import reduce
from operator import or_

dicts = [
    {"a": 1, "b": 2},
    {"c": 99, "d": 3},
    {"e": 4}
]

merged = reduce(or_, dicts, {})
print(merged)

And from reading:

| Bitwise Or | ``a | b`` | ``or_(a, b)`` |

And:

.. function:: or_(a, b)
__or__(a, b)
Return the bitwise or of *a* and *b*.

I wasn't sure if or_ applies also to dictionaries, but according to the trivial implementation, of course it does :). Anyway, I thought it would be nice to rephrase the above 2 parts of the document somehow - not sure exactly how to do phrase it myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions