Let’s say I have an extremely long string with arguments that I want to create. I know you can create a multiline string with
cmd = """line 1
      line 2
      line 3"""
But now lets say I want to pass 1, 2, and 3 as arguments.
This works
cmd = """line %d
      line %d
      line %d""" % (1, 2, 3)
But if I have a super long string with 30+ arguments, how can I possibly pass those arguments in multiple lines? Passing them in a single line defeats the purpose of even trying to create a multiline string.
Thanks to anyone in advance for their help and insight.
Advertisement
Answer
You could abuse the line continuation properties of the parenthesis ( and the comma ,.
cmd = """line %d
      line %d
      line %d""" % (
      1,
      2,
      3)