Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
How to pass an array as an argument to javascript function calling from python using js2py?

I have written some really long functions in javascript already, and now I want to utilise and can't write them again in python, but the data I'm receiving is from python code. So I'm translating the javascript code into python using js2py.translate_file. The data is in a matrix format, so after translating the js file, while I make a call to a function how do I pass the matrix from py file and how do I receive it in the js function?

I know it will be easy to just write the function in py file instead, but I had already written it in js and now I'm desperate to use it from js file, Please help me get this...

This is the code in the py file.

import js2py

js2py.translate_file("j_script.js", "my4.py")
from my4 import *
my4.get_data(mat)

This is the function in the js file that will receive the data.

function get_data(grid_wise){
    
    for(var bi=0; bi<9; bi++){
        for(var ni=0; ni<9; ni++){
            new_new_matrix[bi][ni]=grid_wise[bi][ni];  
        }
    }
    for(var bi=0; bi<9; bi++){
        for(var ni=0; ni<9; ni++){
            reassign(bi, ni);
        }
    }
    console.log(mat_row_wise);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!