for any info/changes follow me: @nickmilon

Hellas.Thebes module

yet some more code snippets named after the ancient city of Thebes

Hellas.Thebes.format_header(frmt)[source]

creates a header string from a new style format string useful when printing dictionaries

Parameters:frmt (str) – a new style format string
Returns:a table header string
assumptions for frmt specs:
  • all have a separator = ‘|’ and include a key size format directive i.e.: ‘{key:size}’
  • no other character allowed in frmt except separator
Example:
>>> frmt = '|{count:12,d}|{percent:7.2f}|{depth:5d}|'
>>> data_dict = {'count': 100, 'percent': 10.5, 'depth': 10}
>>> print(format_header(frmt)); print(frmt.format(**data_dict))
............................
|   count    |percent|depth|
............................
|         100|  10.50|   10|