classification
Title: os.listdir() error if the last folder starts not with the capital letter
Type: Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Djarbore, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Priority: normal Keywords:

Created on 2015-06-24 21:44 by Djarbore, last changed 2015-06-24 21:51 by zach.ware. This issue is now closed.

Messages (3)
msg245777 - (view) Author: Denis Gordeev (Djarbore) Date: 2015-06-24 21:44
My code is:
mypath = 'Z:\Pr Files\norma'
file_list = [ f for f in listdir(mypath) if isfile(join(mypath,f))]

Error:
Traceback (most recent call last):
  File "C:\Documents and Settings\Administrator\Desktop\uni\click zhenilo workshop\noise.py", line 13, in <module>
    file_list = [ f for f in listdir(mypath) if isfile(join(mypath,f))]
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'Z:\\Pr Files\norma/*.*'

It works all right, if the path is:
mypath = 'Z:\Pr Files\Norma'
msg245778 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-06-24 21:48
'Z:\Pr Files\norma' looks wrong '\n' is a single character, a new line. Try to write r'Z:\Pr Files\norma'.

https://docs.python.org/dev/reference/lexical_analysis.html#string-and-bytes-literals
msg245779 - (view) Author: Denis Gordeev (Djarbore) Date: 2015-06-24 21:50
Oh, sorry. Forgot about it.
History
Date User Action Args
2015-06-24 21:51:01zach.waresetstage: resolved
2015-06-24 21:50:13Djarboresetstatus: open -> closed
resolution: not a bug
messages: + msg245779
2015-06-24 21:48:15vstinnersetnosy: + vstinner
messages: + msg245778
2015-06-24 21:44:37Djarborecreate