bugreport os.path.dirname and os.path.basename
Chris Angelico
rosuav at gmail.com
Fri Oct 7 13:38:50 EDT 2016
On Sat, Oct 8, 2016 at 4:34 AM, h2m2 <h2m2 at mailworks.org> wrote:
> os.path.dirname('G:\Programmierung\Python\Portugal
> Training\Python-for-Algorithms--Data-Structures--and--Life\Algorithm
> Analysis and Big O\testFile.ipynb')
>
> result and bug is:
> 'G:\\Programmierung\\Python\\Portugal
> Training\\Python-for-Algorithms--Data-Structures--and--Life'
>
> if I am not mistaken: correct result would be
> 'G:\\Programmierung\\Python\\Portugal
> Training\\Python-for-Algorithms--Data-Structures--and--Life\\Algorithm
> Analysis and Big O'
Not a bug. You have something that you perhaps don't understand:
backslash escapes. When you have "Big O\testfile", that string does
*not* have a backslash in it.
Use raw string literals, forward slashes, or doubled backslashes, to avoid this.
ChrisA
More information about the Python-list
mailing list