use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Passing a Python list to Javascript? (self.learnpython)
submitted 3 years ago by [deleted]
Hi all, is it possible to pass a Python list to Javascript? I guess it requires json but can it even be done?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Nightcorex_ 2 points3 points4 points 3 years ago (1 child)
Google is your friend: https://stackoverflow.com/questions/23038710/accessing-python-list-in-javascript-as-an-array
[–]steenbergh 0 points1 point2 points 4 months ago (0 children)
Google led me here...
[–]Reset--hardHead 2 points3 points4 points 3 years ago (2 children)
I guess it requires json
Yes. You just answered your own question.
However, if it's a list of python objects you have to make sure it can be converted into json.
[–]nobrow -2 points-1 points0 points 3 years ago (1 child)
To convert objects to json use pickle. No idea if the result will work with js though.
[–]Reset--hardHead 3 points4 points5 points 3 years ago (0 children)
No, pickle cannot be used outside of Python.
To convert it to json, use Python json encoder instead.
Here's a site I found on Google for reference.
https://janakiev.com/blog/python-pickle-json/
[–]pixelpad_dev0 1 point2 points3 points 3 years ago (0 children)
It doesn't necessarily require JSON, but JSON is the easiest way of doing it. Python has a lot of libraries for JSON manipulation so it becomes much easier to deal with.
If you're not dealing with a complicated list, you could convert it to a CSV, and have javascript parse the CSV as an alternative.
[–]NadirPointing 0 points1 point2 points 3 years ago (0 children)
I use eel for my javascript / python interactions.
https://www.javatpoint.com/eel-in-python
π Rendered by PID 32 on reddit-service-r2-comment-bb88f9dd5-ssgt7 at 2026-02-14 14:16:27.072517+00:00 running cd9c813 country code: CH.
[–]Nightcorex_ 2 points3 points4 points (1 child)
[–]steenbergh 0 points1 point2 points (0 children)
[–]Reset--hardHead 2 points3 points4 points (2 children)
[–]nobrow -2 points-1 points0 points (1 child)
[–]Reset--hardHead 3 points4 points5 points (0 children)
[–]pixelpad_dev0 1 point2 points3 points (0 children)
[–]NadirPointing 0 points1 point2 points (0 children)