-
I'm trying to work with both Clojure maps and Python dictionaries in my Basilisp code. Could you please provide examples of:
A simple code example showing both conversions would be very helpful. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @wjke-nics, You can use the lisp->python to recursively convert Basilisp data structures into Python data structures,. These includes converting keyword keys into strings by default: basilisp.user=> (lisp->py {:ten {:eleven 11}})
#py {"ten" #py {"eleven" 11}} Use the py->lisp to recursively convert Python data structures into Basilisp data structures. These includes converting string keys into keywords by default: basilisp.user=> (py->lisp #py {"twelve" #py {"thirteen" 13}})
{:twelve {:thirteen 13}} In addition You can use the basilisp.user=> #py {"six" 6}
#py {"six" 6} Use the basilisp.user=> (python/dict {"seven" 7})
#py {"seven" 7} I hope this helps! |
Beta Was this translation helpful? Give feedback.
Hi @wjke-nics,
You can use the lisp->python to recursively convert Basilisp data structures into Python data structures,. These includes converting keyword keys into strings by default:
Use the py->lisp to recursively convert Python data structures into Basilisp data structures. These includes converting string keys into keywords by default:
In addition
You can use the
#py {...}
reader macro to define a Python Dictionary in Basilisp (see Data Readers):Use the
python/dict
function to …