daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Nov 2nd, 2012 1,079 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def mystrlen(s):
  2.         return max(len(line) for line in str(s).split('\n'))
  3.  
  4. def autodetectWidth(data):
  5.         widths = [0]*len(data[0])
  6.         for line in data:
  7.                 for i in range(len(line)):
  8.                         widths[i] = max(widths[i], mystrlen(line[i]))
  9.         return widths
  10.  
  11. # use: myTable.set_cols_width(autodetectWidth(list_of_rows))
  12. # requires an additional iteration over the data, so won't work with generators etc, use list()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top