Windows vs. Linux

OMouse omouse at gmail.com
Tue Aug 1 11:14:10 EDT 2006


That is important, but apparently Windows (at least XP) will work fine
with the forward slash that Linux uses. I just tried it in the command
prompt and it works. I'm sure other platforms use the forward slash
separator as well. You've just covered three major platforms (Mac OS X,
WinXP and Linux) without using os.path.join.

And finally, from the Wikipedia entry on Slash (punctuation):
``Note however that the "forward slash" will be translated into a
backslash by most versions of DOS and Windows, in contexts where there
is little ambiguity with command-line options.''

-Rudolf

James Stroud wrote:
> jean-michel bain-cornu wrote:
> >Take care to use os.sep
>
> This is an important point. You should read up on the os.path module to
> make sure you are doing things in a platform independent way, for
> example, its better to use:
>
>    os.path.join('my', 'favorite', 'dir')
>
> than
>
>    "\\".join(['my', 'favorite', 'dir'])
>
> because the latter will bonk on linux. The former is platform
> independent. This hits at the same issue as using os.sep:
>
>    os.sep.join(['my', 'favorite', 'dir'])
>
> But os.path has takes care of many of these issues in one module.
>
> James
>
> --
> James Stroud
> UCLA-DOE Institute for Genomics and Proteomics
> Box 951570
> Los Angeles, CA 90095
> 
> http://www.jamesstroud.com/




More information about the Python-list mailing list