[Tutor] Expanding a variable with subprocess on Windows
Sander Sweers
sander.sweers at gmail.com
Tue Mar 8 08:38:17 CET 2011
On Tue, 8 Mar 2011, 07:44:31 CET, Becky Mcquilling <ladymcse2000 at gmail.com> wrote:
> gpg = 'c:/program files (x86)/gnu/gnupg/gpg2.exe'
> gpg = 'c:/program files (x86)/gnu/gnupg/gpg2.exe'
>
> subprocess.Popen('gpg', shell=True)
>
> It fails to run gpg and is not expanding the variable. Is there a way
> to do this that I'm missing?
What you are doing is running Popen with a string 'gpg' instead of the variable gpg. The below should do the trick.
subprocess.Popen(gpg, shell=True) # notice no single quotes
Also you usually do not need a shell and I expect your use case runs fine without it.
Greets
sander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110308/d2b3cbfa/attachment-0001.html>
More information about the Tutor
mailing list