Cross-platform file paths

utabintarbo utabintarbo at gmail.com
Fri May 7 12:33:20 EDT 2010


On May 7, 11:23 am, cassiope <f... at u.washington.edu> wrote:
>
> 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

I tried forward slashes:

lst_p = open(os.path.normpath('//serverFQDN/sharename/dir/
filename'),'r').readlines()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '//serverFQDN/sharename/
dir/filename'

BTW, this works on WinXP.

It is as if it does not resolve, yet I have '//serverFQDN/sharename'
mounted, proving that it does resolve. Is this an issue with the way
python deals with the network? It does not seem like a network-only
issue.



More information about the Python-list mailing list