Dear Folks,

I want to execute a command from within python using the subprocess module.

Coming from a Perl background, I thought I could use variable interpolation in strings, but found that this is neither supported nor the Python way. Accordingly, I am a little at sea about how to accomplish it.

I have stated what I am trying to do in the minimal example below:

---
import subprocess

width = 5
height = 30
colors = ['#abcdef]', '#456789']
filename = "/tmp/image.png"

# I want to get the equivalent of variable interpolation in Perl
# so that the command
#
# convert -size 5x30 gradient:#abcdef-#456789 /tmp/image.png
#
# is derived from the variables above
# and executed by subprocess.call() or subprocess.Popen()
# from within Python
#
# Note that the command "convert" is from the ImageMagick suite
# It exists and is executable by the shell;
# the remaining values are arguments.
# The command has been confirmed to execute correctly.
---

Thanks in advance.

Chandra
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to