[Python-ideas] Allow using ** twice

Vernon D. Cole vernondcole at gmail.com
Thu Jun 6 21:36:41 CEST 2013


On Thu, Jun 6, 2013 at 12:47 PM, <python-ideas-request at python.org> wrote:

>
> Does it? All the languages which only allow += on immutable values (e.g.
> Java, C, Javascript) obviously don't mutate anything.


Eh?   It's been twenty years or so since I programmed C for a living, but I
seem to remember that a C variable is actually only a handy label for a
memory location, and that therefore *everything* is mutable -- even when it
shouldn't be. And += was invariably implemented in machine language by a
two-argument add straight to that memory location.  Some of the early C
compilers would even allow you to use a literal on the left side, like "2
+= 3"  which would change the value of the literal '2' to become five.
Made for some interesting bugs!

Ignoring all of that,  if + worked on dictionaries, I would expect that
duplicate keys would receive the value from the right-hand argument, and
that the operation would create a new dictionary.  (and I think it would be
a great +1 idea.)
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130606/32d82a82/attachment.html>


More information about the Python-ideas mailing list