Steven D'Aprano
2006-02-14 12:09:43 UTC
Hello.
E:\files\..................\something.dat
On MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp) described method to access
files with path length
up to 32000 bytes: just add prefix \\?\ to file name.
But when I try to pass prefixed name to file(), I get the same result as when I don't add the prefix: file not found. May be Python
just doesn't support long unicode filenames?
Is there way to open such files?
Backslashes have special meaning to Python and need to be escaped. If youE:\files\..................\something.dat
On MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/naming_a_file.asp) described method to access
files with path length
up to 32000 bytes: just add prefix \\?\ to file name.
But when I try to pass prefixed name to file(), I get the same result as when I don't add the prefix: file not found. May be Python
just doesn't support long unicode filenames?
Is there way to open such files?
f = file("E:\files\...\something.dat", "r")
Python's string escape rules means you are actually trying to open the
file "E:files...something.dat" which doesn't exist.
I seem to be a bit confused about string escaping rules. Only some
backslashes have special meaning, the rest remain in the string.
Sergey, you said UNICODE file names. Not just ordinary strings.
Are you passing a unicode object to the function?
f = file(u"E:\\files\\...\\something.dat", "r")
--
Steven.
Steven.