Using wildcards with Popen in the Subprocess module

kyosohma at gmail.com kyosohma at gmail.com
Thu Mar 15 15:42:36 EDT 2007


On Mar 15, 2:04 pm, William Hudspeth <bhudsp... at edac.unm.edu> wrote:
> Hello,
>
> I am needing to pass an argument to the Popen function of the Subprocess
> module that includes a wildcard in the filename. It seems that Popen is
> not able to expand wildcards, and treats a filename that includes a
> wildcard as a literal.
>
> EX.
>
> var1="/path_to_files/filnames*.doc"
> result=Popen(["command",var1]).wait()
>
> Can anyone tell me how I can work around this problem?
>
> Thanks, Bill

What are you doing, exactly? IF you are just passing in a random
filename, you could do something like this:

var1 = "/path_to_files_/%s" % (filename)

where filename is another variable.

You might also look into using os.system which allows just about any
command line options to be used.

Hope this helps.

Mike




More information about the Python-list mailing list