huffman.py
def recurse(tree, path):
        """
        Traces out all paths in the Huffman tree and adds each
        corresponding leaf value and its associated path to the table.
        """
        if isinstance(tree, TreeLeaf):
            # note, if this is the special end message entry then
            # it stores table[None] = path
            table[tree.value] = path
        elif isinstance(tree, TreeBranch):
            # the trailing , has this properly interpreted as a tuple
            # and not just a single boolean value
            recurse(tree.left, path+(False,))
            recurse(tree.right, path+(True,))
        else:
            raise TypeError('{} is not a tree type'.format(type(tree)))

        Traces out all paths in the Huffman tree and adds each
        corresponding leaf value and its associated path to the table.
        
Traces out all paths in the Huffman tree and adds each
corresponding leaf value and its associated path to the table.
Traces out all paths in the Huffman tree and adds each corresponding leaf value and its associated path to the table .
def recurse(tree, path):
        if isinstance(tree, TreeLeaf):
            table[tree.value] = path
        elif isinstance(tree, TreeBranch):
            recurse(tree.left, path+(False,))
            recurse(tree.right, path+(True,))
        else:
            raise TypeError('{} is not a tree type'.format(type(tree)))
def recurse ( tree , path ) : if isinstance ( tree , TreeLeaf ) : table [ tree . value ] = path elif isinstance ( tree , TreeBranch ) : recurse ( tree . left , path + ( False , ) ) recurse ( tree . right , path + ( True , ) ) else : raise TypeError ( '{} is not a tree type' . format ( type ( tree ) ) )
Traces out all paths in the Huffman tree and adds each
corresponding leaf value and its associated path to the table.
Traces out all paths in the Huffman tree and adds each corresponding leaf value and its associated path to the table .
"""
        Traces out all paths in the Huffman tree and adds each
        corresponding leaf value and its associated path to the table.
        """ # note, if this is the special end message entry then # it stores table[None] = path # the trailing , has this properly interpreted as a tuple # and not just a single boolean value
tree
path