An __or__ method is not meant to be cumulative, as we know.
In box-box operations new_box = box_1 | box_2 , everything is working properly
That said, new_boxwould be different if we would write new_box = box_2 | box_1
The same is with dictionaries ( as introduced in PEP 584), and dict-dict operations.
The problem starts when you combine Box with a dict in an __or__/__ror__ method,
for example new_box = box_1 | dict_1.
Hi,
An
__or__
method is not meant to be cumulative, as we know. In box-box operationsnew_box = box_1 | box_2
, everything is working properly That said,new_box
would be different if we would writenew_box = box_2 | box_1
The same is with dictionaries ( as introduced in PEP 584), and dict-dict operations.
The problem starts when you combine Box with a dict in an
__or__
/__ror__
method, for examplenew_box = box_1 | dict_1
.You can check that:
new_box1 = box_1 | dict_1
,new_box2 = dict_1 | box_1
And you get that -
new_box1 **==** new_box2
As opposed to the noncumulative attribute of OR operation in Dicts and Boxes.
If you would make the change:
new_box1 = box_1 | Box(dict_1)
,new_box2 = Box(dict_1) | box_1
you would get -
new_box1 **!=** new_box2
.But that means that you can't do box operations with normal dicts (at least with OR dunder method)