python 2.7.12 on Linux behaving differently than on Windows

Lew Pitcher lew.pitcher at
Mon Dec 5 11:41:22 EST 2016

On Monday December 5 2016 10:41, in comp.lang.python, "BartC" <bc at>

> On 05/12/2016 15:05, Chris Angelico wrote:
>> On Tue, Dec 6, 2016 at 1:11 AM, BartC <bc at> wrote:
>>> BTW what does Popen() do when one argument is '*.*'? Will that get
>>> expanded to multiple extra arguments, and at what point will it be
>>> expanded?
>> Nope. Popen is not a shell.
>> It sounds as if you want a nerfed shell. Go ahead! I'm sure one
>> exists. It'll frustrate you no end once you get used to a better
>> shell, though - always does when I find myself on Windows...
> That's not the point I was making.
> Say you have this program
>    import sys
>    print (sys.argv)
> And let's say there are just 3 files in the current directory:,
> and
> If run from a Linux shell:
>    python *
> The output is: ['', '', ''] or something along those lines
> (there might be two copies of

And, that's because, before invoking Popen, the SHELL has globbed that '*'
argument into the three filenames and substituted those names where the '*'

If you don't use a shell, then (on Unix), you have to perform the globbing
yourself before invoking Popen.

> Are you saying that if someone executes:
>    subprocess.Popen(["python","", "*"])
> the output will be: ['','*']?
> In that case forget Windows vs. Linux, you now have a program that will
> get command parameters processed differently depending on whether it was
> invoked from a shell or not.


> Or a program that sometimes will see "*" as an argument, and sometimes a
> big list of files that merges into all the other arguments.


Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request

More information about the Python-list mailing list