On the meaning and usage of tuples in Python
I dig the word “tuple”. It sounds like a word you should know but can’t quite place. It makes me think about tipple, as in tippling wine at the gallery opening. That, in turn, reminds me of the Monty Python sketch called “Stock Exchange Report,” in which a reporter broadcasts, “Ting tang tong rankled dithely, little tipples pooped and poppy things went pong!”
But I digress. Back to tuples, a word that sounds like nonsense but is actually a mathematics term meaning an ordered grouping. One of the reasons it sounds familiar even to non-mathematicians is because it makes its way into the language in other ways, such as quintuple, sextuple, and octuple. So, when you think about some poor woman bearing quintuplets, think of them as a pretty darn long grouping of darling babies.
In Python world, a tuple is also like a grouping, consisting of a number of values separated by commas and contained inside parentheses. Here’s an example of a tuple:
pokerFriends = ("Joe", "Shiho", "Jose")
Go ahead and type that into your IDLE shell and hit enter. Now, If you type the word “pokerFriends” into the Shell, it should spit out the tuple:
('Joe', 'Shiho', 'Jose')
So, now you have a tuple (which is a grouping, of course) that is called pokerFriends. The names, which are separated by commas, are the values. We could (and will) go deeper into these matters, but let’s quit for now. Just remember that you tipple wine and tuple values.
Featured image: Dionne quintuplets, 1937, unknown author: https://commons.wikimedia.org/wiki/File:The-dionne-quintuplets_1937.jpg