How to get the filename in the right case ?

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


Stef Mientki schrieb:
> OKB (not okblacke) wrote:
>> Stef Mientki wrote:
>>  
>>>>>> import Module1
>>>>>>           
>>>> d:\data_python_25\pylab_works\module1.py(3)<module>()
>>>>       
>>> -> print "hello"
>>> (Pdb)
>>>
>>>    
>>>> Then we know if PDB is really the culprit.
>>>>
>>>>         
>>> So pdb is the problem.
>>>     
>>
>>         Yep, it does the same thing for me.
>>
>>  
>>>> Apart from that, is that really a problem that the filenames are
>>>> all lower case? AFAIK Windows is case-insensitive regarding
>>>> filenames anyway. So opening the file by just passing the filename
>>>> should work seamless.         
>>> Yes windows is,
>>> but Python is not.
>>> My program should run on Windows and Linux (and maybe a few
>>> others). By converting everything to lowercase, on Linux I can't
>>> distinguishes between 2 files with the same name but a different
>>> case (btw, giving 2 files the same name, only differing in case,
>>> looks like a bad idea to me).
>>>     
>>
>>         Hmmm, but I don't understand what you're doing here.  Are you 
>> somehow storing the filename that pdb outputs and you need to use it 
>> later on a potentially different OS?  If the case is preserved in pdb 
>> on linux, then presumably running it on linux will be fine, right?  
>> It's only a problem if you somehow try to use a filename created by 
>> windows-
>> pdb to open a file (the same file, somehow) on linux.
>>
>>   
> 1. I've a multitab editor.
> 2. When a breakpoint is reached,
> 3. I check if the file specified in pdb output, is already open in one 
> of the editor tabs,
> 4. if not, I open a new tab with the correct file,
> 5. I focus the correct editor tab and jump to the line specified by pdb.
> 6. After that I should be able to inspect the surrounding of the 
> breakpoint, so I need the modules name.
> 
> For 3 I need to compare filenames, the editor contains the case 
> sensitive name, pdb not.
> For 6 I also need the case sensitive filename, but probably there's 
> another way to get the modules name.
> 
> For 3, I can indeed compare the lowercase version of both,
> probably I'll do that for the moment.

You can do that based on the OS - do it on windows (as it doesn't care. 
Actualy, OSX doesn't as well), don't do it on posix systems.

Diez



More information about the Python-list mailing list