Ticket #42 (closed defect: wontfix)
List objects are unhashable
| Reported by: | dfnord@… | Owned by: | xi |
|---|---|---|---|
| Priority: | normal | Component: | pyyaml |
| Severity: | major | Keywords: | |
| Cc: |
Description
Even though yaml specification allows lists ("flow collections on yaml jargon") to be keys, pyaml fails to use them, as lists are unhashable.
For instance, loading "[1, 2]: something" gives the error "found unacceptable key (list objects are unhashable)"
As a away around this, flow collections could be translated into a simple hasheable subclass of list, such as:
class HasheableList(list):
#############################
## Public Methods
#############################
def __hash__(self):
return hash(tuple(self))
Attachments
Change History
Note: See
TracTickets for help on using
tickets.
