Unfortunate exception on dict item assignment (and why aren't slices hashable?)

Ben Finney bignose-hates-spam at and-zip-does-too.com.au
Mon Jul 21 08:59:55 CEST 2003

On Sun, 20 Jul 2003 20:48:16 -0500, Jeff Epler wrote:
>>>> {}[:] = None
> I'd have expected something like 'TypeError: unslicable type' meaning
> that you can't slice a dict, not that slice()s aren't hashable.

You're not requesting to slice a dict; you're requesting to reference an
element of a dict with : as the key.

> In fact, I wonder why slices *aren't* hashable.

How would you store the resulting key; how would you expect it to be
returned from keys() ?

 \       "The right to use [strong cryptography] is the right to speak |
  `\                                          Navajo."  -- Eben Moglen |
_o__)                                                                  |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B

More information about the Python-list mailing list