Friday 28 April 2006 — This is over 18 years old. Be careful.
James Tauber mentions the distinction between lists and tuples in Python. I have to admit: I never made this distinction properly before. I didn’t even think of tuples as immutable lists. They were just the lists with parens, which made them less attractive, because it’s ugly to make one with a single element (that weird orphaned comma), and the parens don’t stand out from the rest of the code as well as square brackets do.
Of course, if you want to modify elements, you have to use a list, and if you want to provide a “list” of element to the string formatting operator, you have to use a tuple. Other than that, I never really thought about it.
Comments
Add a comment: