How to get the filename in the right case ?

Diez B. Roggisch deets at nospam.web.de
Thu Sep 25 06:56:39 EDT 2008


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
pdb.py amounts to one, and that's used to process user-input such
as "Yes", "y", "YES" or whatnot.

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

Diez



More information about the Python-list mailing list