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

108
Views
How to start all print by a tab in Python

I have a script (in Python), that is called by another script (in JavaScript). And to have better readability of the log in my command line, I'd like that all the prints of the subscript (in Python) start with a tabulation. Is there a way to do that with one command, or should I put manually a \t at the beginning of all my print?

I wanted to add the tab in the calling script, but when there are several prints in a row, only the first one gets the tab.

PS: if it can help, the calling of the Python script:

const spawn = require("child_process").spawn;
const pythonProcess = spawn('python3', ["../pythonscript.py"]);
pythonProcess.stdout.on('data', (data) => {          
  buff = Buffer.from(data.toString().trim(), "utf-8");

  console.log('Python answer = ' + buff.toString());
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think this is clearly a post-processing step to be done in Javascript.

Unless you have complete control over your script, there is lots of ways how things might be printed without tab:

  • Strings containing \n
  • automatic log/warning messages from libraries
  • Forgetting the prefix somewhere
  • etc.

Just use buff.toString().split("\n").join("\n\t") in JS.

about 4 years ago · Juan Pablo Isaza Report
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!