How to extend a tuple of tuples?
John Gordon
gordon at panix.com
Mon Sep 12 16:55:40 EDT 2016
In <2349538.mvXUDI8C0e at PointedEars.de> Thomas 'PointedEars' Lahn <PointedEars at web.de> writes:
> >> The obvious way does not work -
> >>
> >> a += (5, 6)
> ^^^^^^
> > Right, because a tuple is immutable.
> How did you get that idea? It has been mutated in the very statement that
> you are quoting
No. An entirely new tuple is created, and 'a' is rebound to it. The
existing tuple is not mutated.
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list