Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complex keys not supported in Map #6

Closed
shaunxcode opened this issue Jun 17, 2013 · 4 comments
Closed

complex keys not supported in Map #6

shaunxcode opened this issue Jun 17, 2013 · 4 comments

Comments

@shaunxcode
Copy link

{[1 2 3] "some numbers"} fails to parse as native dict does not support hashing list.

File "/Library/Python/2.7/site-packages/edn_format/edn_parse.py", line 66, in p_map
p[0] = dict([terms[i:i+2] for i in range(0, len(terms), 2)]) # partition terms in pairs
TypeError: unhashable type: 'list'

@shaunxcode
Copy link
Author

I would suggest when dealing with "complex keys" doing something like

{repr([1, 2, 3]): "some numbers"} ?

@shaunxcode
Copy link
Author

This is of course also affecting using a Map as a key e.g. #{{:foo bar}}

@bitemyapp
Copy link
Collaborator

In [12]: edn_format.loads('{{1 2} "some numbers"}')
Out[12]: {{1: 2}: 'some numbers'}

In [13]: edn_format.loads('{#{1 2} "some numbers"}')
Out[13]: {frozenset([1, 2]): 'some numbers'}

@shaunxcode Map and set work now (we added frozenset/immutable dict) but vectors (lists) do not. Easy solution is switching to tuples by default. We haven't needed it yet.

@swaroopch
Copy link
Owner

This should be working in latest version on pypi, please let us know if otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants