What is a tuple useful for?

后端 未结 11 908
天涯浪人
天涯浪人 2021-02-01 12:45

I am learning Python for a class now, and we just covered tuples as one of the data types. I read the Wikipedia page on it, but, I could not figure out where such a data type wo

11条回答
  •  灰色年华
    2021-02-01 13:24

    A list can always replace a tuple, with respect to functionality (except, apparently, as keys in a dict). However, a tuple can make things go faster. The same is true for, for example, immutable strings in Java -- when will you ever need to be unable to alter your strings? Never!

    I just read a decent discussion on limiting what you can do in order to make better programs; Why Why Functional Programming Matters Matters

提交回复
热议问题