Cross-platform file paths

cassiope fpm at u.washington.edu
Fri May 7 11:23:53 EDT 2010


On May 7, 7:32 am, utabintarbo <utabinta... at gmail.com> wrote:
> Until now, I have used the UNC under Windows (XP) to allow my program
> to access files located on a Samba-equipped *nix box (eg.
> os.path.normpath(r"\\serverFQDN\sharename\dir\filename")). When I try
> to open this file under Linux (Red Hat 5), I get a file not found
> error.
>
> Is there a cross-platform method for accessing files on a network
> share using Python 2.X?
>
> TIA

normpath will convert forward slashes to backslashes on WinXX systems,
but
does not seem to do the reverse on posix systems...so try changing
your
string to use forward slashes.  Also- is the path otherwise the same
on
your Linux system?

HTH..
  -f



More information about the Python-list mailing list