This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: os.listdir() error if the last folder starts not with the capital letter
Type: Stage: resolved
Components: Windows Versions: Python 2.7
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 2022-04-11 14:58 by admin. 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))]

Traceback (most recent call last):
  File "C:\Documents and Settings\Administrator\Desktop\uni\click zhenilo workshop\", 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'.
msg245779 - (view) Author: Denis Gordeev (Djarbore) Date: 2015-06-24 21:50
Oh, sorry. Forgot about it.
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68692
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