On Sat, 26 Apr 2008 19:07:45 +1000, Francesco Bochicchio <[EMAIL PROTECTED]> wrote:

On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote:

hi
i have a directory containing .pgm files of P5 type.i wanted to read
the pixel values of these files ,so as a firststep i wrote code to
make a  list  of filenames using listdir

pgmdir="f:\code\python\pgmgallery" # where i have pgm files
g2=listdir(pgmdir)

i get the following error
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'

i am running python on winXP ..can anyone tell me why i get this
error?

Did you try using a raw string as pathname
pgmdir=r"f:\code\python\pgmgallery"
?

AFAIK, the character '\' in interpreted in Python as the beginning of
an escape sequence (such as '\n') and it should be doubled ( as in the
error message) or a raw string should be used, telling Python that there
are no escape sequences inside.
However, from the message it looks like the path as been understood as
such, so this might not be the case.

Ciao
-----
FB

Neither \c nor \p are escape characters in Section 2.4.1 "String literals".

Could there be some files in that directory whose name is not a valid Windows file name? Windows file names cannot have the following symbols:

\ / : * ? " < > |

--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog";>Software Salariman</a>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to