2

To improve the readability of my code, I want to go to a new line in the code but I do not want the compiler to treat is as a different line of command. How do I do this?

python file_a.py file_b.py
file_c.py file_d.py
  • To clarify, you want to improve the readability of the command that calls python to execute the .py files, not the code within the .py files? – xiota Jul 10 at 6:26
  • Yes, improve the readability of the bash file which calls the python code. – Ashim Jul 10 at 6:39
4

You do this by escaping the newline character, add a backslash \ directly before the line break:

python file_a.py file_b.py \
file_c.py file_d.py

You may indent the second line to further improve readability:

python file_a.py file_b.py \
  file_c.py file_d.py
  • I just tried this but it gives the following error: ./python_bash.sh: line 4: file_c.py file_d..py: command not found – Ashim Jul 10 at 6:38
  • 1
    @user45524 This should work. You are putting the slash immediately before the linebreak? It won't work if there is a space after it. – xiota Jul 10 at 6:41
  • 1
    I think i understand the problem, It seems that I have Windows style line endings (\r\n) - I need to change them to unix style (\n) – Ashim Jul 10 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.