error sending path to Win OS
Michael Hoffman
cam.ac.uk at mh391.invalid
Sat Mar 12 17:16:25 EST 2005
Earl Eiland wrote:
> os.path.getsize(Inputdirectory + '\\' + Filename) works, but
> os.path.getsize(Inputdirectory + '\\' + Filename.split('.') + '.ext')
> Fails reporting "no such file or directory
> InputDirectory\\Filename.ext".
No, that should be a TypeError. This will be easier if you copy and
paste your Python session instead of making stuff up.
> os.path.getsize(Inputdirectory + r'\' + Filename.split('.') + '.ext')
> generates a syntax error.
'r"\" is not a valid string literal (even a raw string cannot end in an
odd number of backslashes). Specifically, a raw string cannot end in a
single backslash (since the backslash would escape the following quote
character). Note also that a single backslash followed by a newline is
interpreted as those two characters as part of the string, not as a
line continuation.'
http://docs.python.org/ref/strings.html
--
Michael Hoffman
More information about the Python-list
mailing list