align on char

Tor Iver Wilhelmsen tor.iver.wilhelmsen at broadpark.no
Thu Jun 17 16:23:00 EDT 2004


Jeff Epler <jepler at unpythonic.net> writes:

> ...     width = max([len(i[0]) for i in seq])
> ...     return ["%s:%s" % (a.ljust(width), b) for a, b in seq]

You can also do a
   fmt = "%" + str(-max) + "s : %s"
   return [fmt % (a, b) for a, b in seq]

instead of that last line. Dunno if that's more readable, though. :)



More information about the Python-list mailing list