python 2.7.12 on Linux behaving differently than on Windows

Michael Torrie torriem at gmail.com
Thu Dec 8 02:06:43 EST 2016


On 12/07/2016 11:26 PM, Gregory Ewing wrote:
> BartC wrote:
>>  println dirlist(cmdparams[2])        # Windows
>>  println tail(cmdparams)              # Linux
> 
> I'm not familiar with your language, so I'll reply
> in Python. If you write it like this:
> 
>     for arg in sys.argv[1:]:
>        for name in glob(arg):
>           print(name)
> 
> then the user will be able to invoke it the same way
> on both systems.

With the caveat that certain filenames may cause issues on Linux.  For
example, a file like "Chicago - Will You Still Love Me?.ogg".  Or a
filename with a "*" in the name.  Probably it would still work since
each of these filenames when taken as a glob actually match themselves
when expanded.  But they could match other files too that the user did
not want to pass in.

Personally I'd include logic to only run args through glob if I was on
Windows.

These are the perils of cross-platform compatibility.



More information about the Python-list mailing list