Why tuple is not mutable in Python? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why are python strings and tuples are made immutable? What lower-level design makes tuple not mutable in Python? Why this feature is useful? 回答1: A few reasons: Mutable objects like lists cannot be used as dictionary keys or set members in Python, since they are not hashable. If lists were given __hash__ methods based on their contents, the values returned could change as the contents change, which violates the