Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Are tuples immutable?
#11
This can be also worth of knowing about tuples immutability:

>>> spam = (1, [2, 3])
>>> spam[1] += [4, 5]            # will throw error but still mutate list within tuple
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>> spam
(1, [2, 3, 4, 5])
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Are tuples immutable? - by python_user_n - Jan-06-2019, 01:00 PM
RE: Are tuples immutable? - by perfringo - Jan-06-2019, 01:53 PM
RE: Are tuples immutable? - by buran - Jan-06-2019, 02:27 PM
RE: Are tuples immutable? - by python_user_n - Jan-06-2019, 02:41 PM
RE: Are tuples immutable? - by buran - Jan-06-2019, 03:06 PM
RE: Are tuples immutable? - by ichabod801 - Jan-06-2019, 03:28 PM
RE: Are tuples immutable? - by python_user_n - Jan-06-2019, 04:24 PM
RE: Are tuples immutable? - by ichabod801 - Jan-06-2019, 04:39 PM
RE: Are tuples immutable? - by micseydel - Jan-06-2019, 04:46 PM
RE: Are tuples immutable? - by python_user_n - Jan-06-2019, 05:21 PM
RE: Are tuples immutable? - by perfringo - Jan-07-2019, 08:04 AM
RE: Are tuples immutable? - by python_user_n - Jan-07-2019, 08:08 AM
RE: Are tuples immutable? - by buran - Jan-07-2019, 11:12 AM
RE: Are tuples immutable? - by python_user_n - Jan-07-2019, 01:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  immutable types Skaperen 2 2,085 Jul-09-2021, 01:00 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020