import ntpath


def fileparts(n):
    """
    p,n,e = fileparts(filename)    
     
    fileparts(r'c:\blah\BLAH.jpg') returns ('c:\blah','BLAH','.jpg')
     
    Note that the '.' lives with the extension, and separators have been removed.
    """
    
    p = ntpath.dirname(n)
    basename = ntpath.basename(n)
    n,e = ntpath.splitext(basename)
    return p,n,e