• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Passing Unknown Number Of Arguments to Python Script from NodeJS via Command Line

Resolved: Passing Unknown Number Of Arguments to Python Script from NodeJS via Command Line

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a node server that executes an external python script via

child_process execFile()


I have no problem executing it with a known number of arguments i just pass it like
However i need to pass changing number of arguments because i do not know how many elements my data is going to have. How can i pass all the elements of an array (with changing length) into this python script (as arguments).
I do not have access to the python script but python script is ideally able to read unlimited number of arguments and i only can pass arguments via command-line

Answer:

Using the spread operation to spread arrays (...) you can create a function that accepts unlimited amount of arguments and you spread those arguments into the execFile

If you have better answer, please add a comment about this, thank you!

child-process command-line javascript node.js
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Resolved: How can I implement a function depending on picked up items?

01/04/2023

Resolved: Azuer Service Bus SDK not receiving the specified messages

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.