def reversed_dotted_parts(s):
    """
    For a string "a.b.c", yields "a.b.c", "a.b", "a".
    """
    idx = -1
    if s:
        yield s
    while s:
        idx = s.rfind('.', 0, idx)
        if idx == -1:
            break
        yield s[:idx]
For a string "a.b.c", yields "a.b.c", "a.b", "a".