Can tuples be replaced with lists all the time?

Paul Rubin no.email at nospam.invalid
Sat Feb 22 23:28:54 EST 2014


Sam <lightaiyee at gmail.com> writes:
> My understanding of Python tuples is that they are like immutable
> lists. If this is the cause, why can't we replace tuples with lists
> all the time (just don't reassign the lists)? 

You can do that a lot of the time but not always.  For example, you can
use a tuple as a dictionary key, but not a list, since keys are supposed
to be immutable.



More information about the Python-list mailing list