Peter Otten wrote:
import subprocess

def convert(width=5, height=30, colors=['#abcdef', '#456789'],
            filename="tmp/image with space in its name.png"):
    lookup = locals()
    assert all("\n" not in str(s) for s in lookup.values())
    subprocess.call("""\
convert
-size
{width}x{height}
gradient:{colors[0]}-{colors[1]}
{filename}""".format(**lookup).splitlines())

convert()

Peter

One other question I forgot to ask is this why is there a terminal backslash in

subprocess.call("""\

Removing the backslash makes the function fail.

I wonder why, because """ is supposed to allow multi-line strings. I am sorry if this sounds obtuse but that backslash baffles me.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to