windows / unix path

MRAB google at mrabarnett.plus.com
Mon Oct 20 18:44:05 EDT 2008


On Oct 20, 4:47 pm, Larry Bates <larry.ba... at vitalEsafe.com> wrote:
> Marcin201 wrote:
> > Is there an built-in functionality in python to convert Windows paths
> > to Unix paths?  I am running into problems when creating data files on
> > Windows and the running them on a Unix platform.  I create paths using
> > os.path.join.
>
> > os.path.join('Pictures', '01.jpg') returns 'Pictures\\01..jpg' on
> > Win.  When I read files created on Win under Unix this is a problem,
> > python cannot open 'Pictures\\01.jpg'
>
> > Thanks,
>
> > Marcin
>
> I use posixpath when I want to "force" forward slashes that I know will work on
> Linux.  Actually the forward slashes work fine on Windows also (undocumented
> feature of Windows).
>
FYI, in Windows the standard is for commandline options to begin with
a slash, eg dir /b, but as long as the path doesn't begin with one
you'll be OK. :-)



More information about the Python-list mailing list