[Tutor] Expanding a variable with subprocess on Windows
Becky Mcquilling
ladymcse2000 at gmail.com
Tue Mar 8 09:15:57 CET 2011
Thanks, Sander. That was simple enough, as I'm learning I sometimes get
caught up in these all too silly mistakes.
Becky
On Mon, Mar 7, 2011 at 11:38 PM, Sander Sweers <sander.sweers at gmail.com>wrote:
> 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/878cf439/attachment.html>
More information about the Tutor
mailing list