[Python-ideas] Allow using ** twice
Oleg Broytman
phd at phdru.name
Thu Jun 6 23:45:31 CEST 2013
On Thu, Jun 06, 2013 at 05:30:41PM -0400, Devin Jeanpierre <jeanpierreda at gmail.com> wrote:
> On Thu, Jun 6, 2013 at 3:33 PM, Peter Jung <ilmiacs at gmail.com> wrote:
> > I'd take "+= is not allowed" as synonymous to "is immutable".
>
> >>> a = (1,2)
> >>> a += (3, 4)
> >>> a
> (1, 2, 3, 4)
>
> By this definition, tuples are not immutable. That would be
> nonstandard terminology.
>
> I think you've confused "mutability" of variables (more clearly:
> rebindability) with mutability of objects.
It's quite easy to explain the difference:
>>> l = [1, 2]
>>> id(l)
3071923884L
>>> l += [3, 4]
>>> id(l)
3071923884L
>>>
>>> t = (1, 2)
>>> id(t)
3074977068L
>>> t += (3, 4)
>>> id(t)
3075097020L
Lists are updated in-place. Tuples are recreated.
Oleg.
--
Oleg Broytman http://phdru.name/ phd at phdru.name
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-ideas
mailing list