[Tutor] why strings immutable

D-Man dsh8290@rit.edu
Fri, 13 Jul 2001 15:27:35 -0400


On Fri, Jul 13, 2001 at 01:54:07PM -0500, Lloyd Hugh Allen wrote:

| Someone had asked, "Why are strings immutable?"
| 
| Here's a guess: I recall having read that mutable objects are not
| allowed to be dictionary keys

More precisely, non-hashable objects aren't allowed to be dict keys.
Mutable objects (such as lists) typically are not hashable.

| , and it would be a Good Thing to be able to use strings as
| dictionary keys (otherwise we'd probably want to call dictionaries
| something else, if they couldn't hold representations of words).

Sounds like a good idea to me :-).

-D