Skip to content

Instantly share code, notes, and snippets.

def max_col_widths(table):
"""
Return a list with the widest column length in
each column from the table.
"""
result = []
for column in zip(*table):
max_ = 0
for elem_in_column in column:
max_ = max(len(str(elem_in_column)), max_)
@bolry
bolry / robust_pathmunge.shinc
Last active March 5, 2016 15:45
Robust pathmunge
# will prepend or define XPATH with the value unless it already exists
# any empty arguments will not be added
robust_prepend()
{
case ":${XPATH-}:" in
*:"${1-}":*) ;;
*) XPATH="${1-}${XPATH:+${1:+:}$XPATH}"
esac
}