Maxximiliann

Maxximiliann

Converting an Elixir list into a Python dictionary

What libraries, if any, can be used to take an Elixir list: [color: "Red", make: "Mclaren", mileage: 15641.469] and convert into a Python dictionary - {"color": "Red", "make": "Mclaren", "mileage": 15641.469}?

If no such libraries exist, what approach would you recommend to accomplish this efficiently?

Most Liked

hauleth

hauleth

What you mean by “convert”? If you want to send it to the other program then you need to serialise it into some format understood by the both parties and then send it. For example you can use JSON, BARE, ProtoBuf, bencode, ETF, Cap’n’proto or almost any other format out there.

gregvaughn

gregvaughn

That python example looks like json

iex(2)> [color: "Red", make: "Mclaren", mileage: 15641.469] |> Map.new |> Jason.encode!
"{\"color\":\"Red\",\"make\":\"Mclaren\",\"mileage\":15641.469}"
aenglisc

aenglisc

You could probably look for some ETF library for Python. Not sure if there are any though.

Where Next?

Popular in Discussions Top

PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
AstonJ
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them? Feel free to be as concise or in-depth as you li...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
mikl
I wanted to capitalize a string, and tried using String.capitalize(). That generally works well, until you try to capitalize a word like...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54092 488
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement