why is os.getcwd() printing the path in all caps on win2k?

sameer sameer_ at email.com
Wed Jan 23 02:08:18 EST 2002


I believe it's a DOS compatibility issue.  i was planning on writing
an installation script that would move the contents of the current
directory to another directory.  I guess I'll have to find another
way.  Looks like in dos mode, any case sensitivity is lost and
everything is capitalized.

C:\>cd programs

C:\PROGRAMS>cd python

C:\PROGRAMS\PYTHON>python
ActivePython 2.1.1, build 212 (ActiveState)
Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on
win32
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd()
'C:\\PROGRAMS\\PYTHON'
>>>

when not in DOS mode, everything works as expected.

C:\>python
ActivePython 2.1.1, build 212 (ActiveState)
Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on
win32
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> os.mkdir(r'c:\longDirectoryName')
>>> os.chdir(r'c:\longDirectoryName')
>>> os.getcwd()
'c:\\longDirectoryName'
>>> os.chdir(r'c:\programs\python\lj')
>>> os.getcwd()
'c:\\programs\\python\\lj'
>>>



"Jimmy Retzlaff" <jimmy at retzlaff.com> wrote in message news:<mailman.1011693151.20776.python-list at python.org>...
> >> can anyone tell me why os.getcwd() prints out the path in all caps on
> >> win2k at least?
> 
> It works fine on my Windows 2000 Server (SP2 w/IE6) using Python 2.2
> (I'm quite sure it was the same on 2.1.1):
> 
> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import os
> >>> os.getcwd()
> 'C:\\Python22'
> 
> There are several possible reasons within Windows for what you are
> seeing including UI settings and the file system of your partition. One
> possible reason for the difference is that your directories really are
> all caps and Explorer is lying to you when you look at it there. Some
> versions of Explorer (affected by version of Windows and version of IE)
> default to displaying an upper case name like C:\PYTHON as C:\Python.
> It's also possible that it's giving you the DOS/8.3 compatible name. Try
> this:
> 
> >>> os.mkdir(r'c:\longDirectoryName')
> >>> os.chdir(r'c:\longDirectoryName')
> >>> os.getcwd()
> 'c:\\longDirectoryName'
> 
> Depending on how things are set up, you could see something like
> 'C:\\LONGDI~1' which is the DOS/8.3 compatible name. You can also see
> the 8.3 names by doing "dir /x" at a command prompt.
> 
> If you get an exception in the above snippet, then it's likely that your
> file system doesn't support long file names (and hence mixed case) at
> all.
> 
> Jimmy



More information about the Python-list mailing list