def column_spec(name, func, width, padding_right=5, padding_left=5, align='right', vertical_align='middle'):
    """
    Returns a function html_table_cell(item, header=False) that generates HTML for table cells
    <td> for header == False and <th> for header == True according to the specification defined
    by the input arguments, see below for more detail.

    :param name: name of the column, this will be the string displayed in a header cell, in case header == True
    :param func: callable. The value returned by func(item) will be displayed in a table cell, in case header == False
    :param width: width of the column in pixels
    :param padding_right: right padding, in pixels of the table cell; default is 5 pixels
    :param padding_left: left padding, in pixels of the table cell; default is 5 pixels
    :param align: alignment of the table cell; default is 'right'

    :return: function
    """
    def html_table_cell(item, header=False):

        if header:
            return '<th align={0} vertical-align={5} style="spacing:0;padding-left:{1}px;padding-right:{2}px;" width={3}>{4}</td>'.\
                   format(align, padding_left, padding_right, width, name, vertical_align)
        else:
            return '<td align={0} vertical-align={4} style="spacing:0;padding-left:{1}px;padding-right:{2}px;">{3}</td>'.\
                   format(align, padding_left, padding_right, func(item), vertical_align)

    return html_table_cell