[Python-ideas] Allow using ** twice

MRAB python at mrabarnett.plus.com
Thu Jun 6 21:51:06 CEST 2013


On 06/06/2013 19:46, Haoyi Li wrote:
>  > That would make += misleading. In any other language with a +=
> operator, it mutates
>
> Does it? All the languages which only allow += on immutable values (e.g.
> Java, C, Javascript) obviously don't mutate anything. C# does a straight
> desugar into a = a + b. Scala allows you to override it separately, but
> the vast majority of them (by default) are simple desugars into a = a +
> b. Not familiar with how C++ does it, perhaps someone could chime in?
>
> I don't know the answer, but I don't think it's obvious at all that +=
> mutates. What (non-python) background are you coming from where this is
> common practice?
>
> Anyway, this is all bikeshedding. Regardless of how the AugAssign
> operators work, I think that having dict_a + dict_b merge dict_a and
> dict_b, with dict_a's keys taking precedence, would be a wonderful thing!
>
Except that dict a'b keys should take precedence. :-)



More information about the Python-ideas mailing list