How to get the filename in the right case ?

Stef Mientki stef.mientki at
Thu Sep 25 13:49:06 CEST 2008

Diez B. Roggisch wrote:
> Stef Mientki wrote:
>> hello,
>> How can I find the correct case of a filename ?
>> Background in my program I use case sensitive filenames, just like
>> Python requires.
>> Now I've integrated pdb into the program,
>> but pdb acts somwhat strange:
>> upon a breakpoint it gives the filename always in lowercase (probably
>> this only happens on windows).
>> So is there a way to get the correct case of a given filename in lowercase
>> ?
>> One solution might be to make the comparison in my program always with
>> lowercase,
>> but then I'm sure the program won't work on non-windows systems.
>> btw, why does pdb behave that way ( Python 2.5 ) ?
> I doubt it does. It sure doesn't on unix, and I fail to see any reason why
> it should do that on windows - given that the total number of lower() in
> amounts to one, and that's used to process user-input such
> as "Yes", "y", "YES" or whatnot.
Yes I'm pretty sure, two reasons:
1. when I perform a step_into, jumping into a file that doesn't have 
breakpoints itself (meaning my program doesn't even know of this file),
pdb returns a lowercase filename
2. rpdb2 (probably based or even inherited from pdb) has the same 
behavior. Asking the writer of rpdb2, I got some excuse (which I didn't 
understand) why he had done it that way.

>  Are you sure you are not processing the content through some lower()-call
> when embedding pdb? 
But maybe pdb does ?

thanks anyway,
> Diez
> --

More information about the Python-list mailing list