Library os.path.isfile(filename) - long filenames error.

Peter Hansen peter at engcorp.com
Fri Nov 30 14:40:56 CET 2001


Clayton Brown - Emmie Osawa wrote:
> 
> The python os.path.isfile() function gets a system error:
> "Filename or extension is too long." when tested on this file..
> 
> "c:\path\path\path\kddf-slgjsfdljgklsj+=lkjdlfks
> jdlfkjsdk_lfjsdklfj+=ljk sjflksdj fklsdjf.ext"

There's no reason that filename shouldn't work, although
as written you might be implying it has an embedded newline
(between the two lines? or is that just a space) and 
in addition you might want to use one of the following
instead of what you wrote:

 "c:\\path\\path\\path\\kddf- .....
 r"c:\path\path\path\kddf- ...
 "c:/path/path/path/kddf- ...

(because without those, in some cases, the backslash
before the character will turn it into a special code,
such as if you had c:\test\test which has embedded tabs).

os.path.isfile() returned true on my machine (Win 98)
for that filename.

Best answer if you can't figure it out: type it in
the interactive prompt and then cut and paste the
resulting error message (and what you typed!) into
the newsreader window and post that.

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list