error sending path to Win OS

Paul Watson pwatson at redlinepy.com
Sun Mar 13 07:05:47 EST 2005


"Earl Eiland" <eee at nmt.edu> wrote in message 
news:mailman.329.1110662097.1799.python-list at python.org...
> os.path.getsize(Inputdirectory + '\\' + Filename) works, but
> os.path.getsize(Inputdirectory + '\\' + Filename.split('.') + '.ext')
> Fails reporting "no such file or directory
> InputDirectory\\Filename.ext".
> os.path.getsize(Inputdirectory + r'\' + Filename.split('.') + '.ext')
> generates a syntax error.
>
> Earl Eiland

Use the language provided os.sep rather than trying to code your own which 
will be incorrect when the code is run on a different platform.

$ python
Python 2.1 (#15, May  4 2004, 21:22:34) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> dir(os)
...
>>> os.sep
'\\'
>>> os.pathsep
';'
>>> os.linesep
'\r\n' 





More information about the Python-list mailing list