[Python-ideas] Allow using ** twice

MRAB python at mrabarnett.plus.com
Thu Jun 6 18:03:03 CEST 2013


On 06/06/2013 16:17, Haoyi Li wrote:
>  > I read `dict1 | dict2` as a mapping that would try dict1 *or* dict2 if
> the key is not in dict1.
>
> Idea:
>
> dict1 + dict2 -> dict2 takes priority
> dict1 | dict2 -> dict1 takes priority
>
> Does that make sense to anyone? Both + and | are currently un-used iirc.
>
It occurs to me that 'Counter' is dict-like, but already uses both +
and |.

Would there be any times when you want to merge Counter instances in
the same manner? It could be confusing if you thought of them as
dict-like but they didn't behave like dicts...


More information about the Python-ideas mailing list