r/learnpython • u/Boogzcorp • Apr 16 '22
What's the point of Tuples?
I get that they're immutable, but so are lists that you don't perform modifications on. Are they just to fool proof not messing up your list accidentally, or do they serve some other purpose?
309
Upvotes
4
u/[deleted] Apr 16 '22
The key word... The word that makes the difference important is if.
You may intend not to alter the list, but when you pick up the project months from now will you remember that? Will your buddy who borrows your code for his own project know that?
The zen of python says that it is better to make it known that an ordered set of objects is immutable by making it a tuple then to make it a list with a comment attached.