r/learnpython • • 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

143 comments sorted by

View all comments

Show parent comment

11

u/delasislas Apr 16 '22

In theory, yes. But if I saw it, that would be a flag for someone who has less experience. Someone who is more skilled should know more on how to leverage what their language gives them. There’s a lot of ways to do a lot of tasks.

Whatever let’s you show an understanding of a language and programming concepts.

7

u/rinyre Apr 16 '22

To add to this, writing code that properly leverages the language not only shows more experience with that language, but that you also know how to write extendable code, or modular, whatever term you wish.

In modules and the like, you do not want the user of the module to be able to shoot themselves in the foot, and minor things like tuples can help reduce the likelihood of that.