Accessing a path which case sensitive without writing so
Question: I would like to know whether it possible to access linux path like:
`/home/dan/CaseSensitivE/test.txt`

In a way we write it as `/home/dan/casesensitive/test.txt` and it goes to the
right place, means python consider paths as not case sensitive and allow
entering them that way, although they are case sensitive.


Answer: As Klaus said, the simple answer is no. You could, however, take a more
laborious route, and enumerate all folders/files in your top directory
(`os.path, glob`), convert to lower case (`string.lower`), test equality, step
one level down, etc.

This works for me:

    
    
    import os
    
    def match_lowercase_path(path):
        # get absolute path
        path = os.path.abspath(path)
    
        # try it first
        if os.path.exists(path):
            correct_path = path
        # no luck
        else:
            # works on linux, but there must be a better way
            components = path.split('/')
    
            # initialise answer
            correct_path = '/'
    
            # step through
            for c in components:
                if os.path.isdir(correct_path + c):
                    correct_path += c +'/'
                elif os.path.isfile(correct_path + c):
                    correct_path += c
                else:
                    match = find_match(correct_path, c)
                    correct_path += match
    
        return correct_path
    
    def find_match(path, ext):
        for child in os.listdir(path):
            if child.lower() == ext:
                if os.path.isdir(path + child):
                    return child + '/'
                else:
                    return child
        else:
            raise ValueError('Could not find a match for {}.'.format(path + ext))
    

