def group_by_length(words):
    """Returns a dictionary grouping words into sets by length.

    >>> grouped = group_by_length(['python', 'module', 'of', 'the', 'week'])
    >>> grouped == {2: set(['of']),
    ...             3: set(['the']),
    ...             4: set(['week']),
    ...             6: set(['python', 'module']),
    ...             }
    True
    """
    d = {}
    for word in words:
        s = d.setdefault(len(word), set())
        s.add(word)
    return d