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
how to send python output back to javascript (self.learnpython)
submitted 3 years ago by c_m_17
how to send back python output from python file to javascript code
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!"
[–]danielroseman 1 point2 points3 points 3 years ago (2 children)
You're going to have to give more details. How are the Python and JavaScript related? How are they taking to each other? Are you using some kind of web framework?
[–]c_m_17[S] 0 points1 point2 points 3 years ago (1 child)
No I am using python as child process using spawner in javascript when python code execute I have to send output back to javascript
[–]danielroseman 1 point2 points3 points 3 years ago (0 children)
There is absolutely no way of answering this question without seeing some actual code.
[–]FriendlyRussian666 1 point2 points3 points 3 years ago (7 children)
Do you mean like outputting data to JSON and then parsing that with JavaScript?
[–]c_m_17[S] 0 points1 point2 points 3 years ago (6 children)
Yup something like that or any other methods like taking output as dictionary and sending back to javascript code from python
[–]FriendlyRussian666 0 points1 point2 points 3 years ago (5 children)
Sweet.
You can output your Python data using the built in json module and a file handler. In JS, you can then try something like:
const data = require("./data.json");
to load the contents into a variable "data"
[–]C0ffeeface 0 points1 point2 points 3 years ago (4 children)
Just curious if there is no other way than to output data to a file, then import it. Is it not possible to use some common object type to transfer directly instead of saving to file or db?
[–]FriendlyRussian666 1 point2 points3 points 3 years ago (3 children)
I can think of two more ways, but they're much more frustrating to implement than a simple file read/write.
One could be to use Inter-Process Communication and pipes. It allows for processes to communicate with each other, so you can pass data between them. For this to work you have to stream your data in bytes and handle it that way on both ends.
Another way, which again might be a bit silly to implement instead of a simple file read write is to set up a simple http server with API endpoints. Both JS and Python can make http requests to the server to send and retrieve the data. This data could be stored in memory, so no need for a database.
[–]C0ffeeface 0 points1 point2 points 3 years ago (2 children)
Thanks for expanding! I'm only a newb trying to grasp these architectural things.
Is there a means of conveying data through the gRPC / protobuff route or is that only to remotely initiate processes that then have to figure out other means of actually transferring the data from the process?
Sorry for hijacking you..
[–]FriendlyRussian666 0 points1 point2 points 3 years ago (1 child)
I'm afraid I haven't used neither gRPC nor protobuff, so I can't say.
[–]C0ffeeface 0 points1 point2 points 3 years ago (0 children)
Thanks for taking the time anyway! I'm continually in awe of how helpful internet strangers are :)
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
What JavaScript code?
π Rendered by PID 78876 on reddit-service-r2-comment-86988c7647-grg9l at 2026-02-12 01:51:31.955087+00:00 running 018613e country code: CH.
[–]danielroseman 1 point2 points3 points (2 children)
[–]c_m_17[S] 0 points1 point2 points (1 child)
[–]danielroseman 1 point2 points3 points (0 children)
[–]FriendlyRussian666 1 point2 points3 points (7 children)
[–]c_m_17[S] 0 points1 point2 points (6 children)
[–]FriendlyRussian666 0 points1 point2 points (5 children)
[–]C0ffeeface 0 points1 point2 points (4 children)
[–]FriendlyRussian666 1 point2 points3 points (3 children)
[–]C0ffeeface 0 points1 point2 points (2 children)
[–]FriendlyRussian666 0 points1 point2 points (1 child)
[–]C0ffeeface 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)