Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
gakada
on Aug 20, 2016
|
parent
|
context
|
favorite
| on:
Python Lists vs. Tuples
Tuples are immutable so that they can be used as keys in hash tables.
kazinator
on Aug 20, 2016
[–]
But a sibling comment to yours by shoyer argues that mutable objects can be elements of a tuple. A tuple whose elements are mutable is effectively mutable.
Can (1, 2, [3]) be used in a hash table, and what if the [3] is mutated to [3, 4]?
philipov
on Aug 20, 2016
|
parent
[–]
When it tries to hash the tuple, it finds the list inside of it, realizes the tuple is mutable, and throws an error.
Consider applying for YC's Spring batch! Applications are open till Feb 11.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: