-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
cannot get key from dictionary #183
Comments
Hmm. as-python here means the dictionary is bridged and you used a keyword argument. There is no way to pass a keyword through python and back to clojure,however, so when querying it fails. Keywords are marshalled to strings when passing back to python so I think the issue is don't use java-specific types as keys when using bridged dictionaries. I don't see a great way around this. |
Maybe writing the code like this, shows the issue better: (def py-dict (py/as-python {:a 1}))
(seq (py/py. py-dict keys))
-> ("a")
(py/py. py-dict get "a")
->nil I am able to create a "dictionary", which
This seems to break the contract of a dictionary. and exactly the same code, does work, if I give a string initially: (def py-dict (py/as-python {"a" 1}))
(seq (py/py. py-dict keys))
-> ("a")
(py/py. py-dict get "a")
->1 In my view, the object created by |
The created python object behaves very strange... (def py-dict (py/as-python {:a 1}))
(seq (py/py. py-dict items))
(('a', None)) ;; value of "a" is None ....
(seq (py/py. py-dict values))
(1) ;; list of values is: (1) I am not expecting to get a python-object having a "keyword", as keyword are not supported in python. dict(a=1) neither. |
That is a good point and definitely one issue here. |
The below code seems to be inconsistent.
Converting a Clojure map to a python dictionary shows presence of key "a".
But then I can not get the key "a" out of it.
The text was updated successfully, but these errors were encountered: