[ python-Bugs-1733184 ] slice type is unhashable
SourceForge.net
noreply at sourceforge.net
Fri Jun 8 07:24:42 CEST 2007
Bugs item #1733184, was opened at 2007-06-07 21:30
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1733184&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: L. Peter Deutsch (lpd)
Assigned to: Nobody/Anonymous (nobody)
Summary: slice type is unhashable
Initial Comment:
Patch # 408326 is a "bug fix" that makes slice objects comparable but explicitly NOT hashable. I don't understand why Guido thinks this is the right behavior for them: they are immutable, have well-defined state, do not include references to mutable objects, and can be compared property for equality. Why shouldn't they be usable as dictionary keys? I have an application that really would like them to be usable as such. I know I can define a class Slice of my own .. but that seems so silly.
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-06-08 00:24
Message:
Logged In: YES
user_id=80475
Originator: NO
FWIW, you have a easy work-around. Use repr(yourslice) as the dictionary
key.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1733184&group_id=5470
More information about the Python-bugs-list
mailing list