Title: filedialog.askdirectory inconsistent on Windows between returning "C:/" and "C:/users" (no trailing slash)
Type: behavior Stage: resolved
Components: Tkinter, Windows Versions: Python 3.3, Python 3.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Grant Hillebrand, paul.moore, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-07-25 17:37 by Grant Hillebrand, last changed 2016-07-25 17:50 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg271296 - (view) Author: Grant Hillebrand (Grant Hillebrand) Date: 2016-07-25 17:37
When running the following code on Windows 7 (64bit os), and selecting a root drive letter, eg C:, it returns "C:/", with a slash appended. When selecting any other path below root level, eg "C:/users" it returns "C:/users" - no slash appended. 
This then introduces an odd edge case in processing the output if the path is to be prepended to directory walk data and other file names.

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32

>>> from tkinter import filedialog
>>> SourcePath = filedialog.askdirectory()
>>> print(SourcePath)
>>> SourcePath = filedialog.askdirectory()
>>> print(SourcePath)
msg271299 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-07-25 17:50
"C:" is current directory on drive C, "C:/" is root directory on drive C. This is not related to Python or Tk, this is how paths work.

Use os.path or pathlib for processing paths.
Date User Action Args
2016-07-25 17:50:26serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg271299

resolution: not a bug
stage: resolved
2016-07-25 17:37:18Grant Hillebrandcreate