MonoTable Class Variables

MonoTable.format_func = <built-in function format>

User defined function with signature of <built-in function format>.

This function is selected for cell formatting except when a column format string directives specifies a format function.

These Format Functions can be used here.

When overriding in a subclass definition use the result of Python built in function staticmethod() like this:

>>> import monotable
>>> def your_user_defined_format_function(value, format_spec):
...    pass
>>> class SubclassMonoTable(monotable.MonoTable):
...     format_func = staticmethod(your_user_defined_format_function)
>>> tbl = SubclassMonoTable()
>>>
>>> # When overriding on an instance do not use staticmethod like this:
>>>
>>> tbl = monotable.MonoTable()
>>> tbl.format_func = your_user_defined_format_function

Reading Python functions and methods Docs Here helps explain when to use built in function staticmethod().

MonoTable.format_exc_callback = <function raise_it>

Function called when format_func raises an exception.

The function takes the argument MonoTableCellError and (if returning) returns the string to be returned by format_func.

These Format Function Error Callbacks can be used here.

Please see advice at format_func about when to use staticmethod().

MonoTable.default_float_format_spec = '.6f'

Default format specification for float type.

Applies only to cells that satisfy all of:

  • cell value is type float
  • format function is <built-in function format>
  • format_spec is the empty string

If the cell is not type float or a different format function is set, this will not apply.

This sets the precision to align the decimal points in a column of floats. This is useful when a column contains floats and strings. The presence of strings prevents the use of a float format_spec for the column.

Disable this feature by setting to the empty string. This feature applies to the entire table.

MonoTable.format_none_as = ''

Value placed in table for cell of type None.

MonoTable.sep = ' '

String that separates columns in non-bordered tables.

sep after a column can be overridden by the format string directive rsep.

MonoTable.separated_guidelines = False

When True guidelines will have the sep characters between columns.

This looks good when the seps are all spaces. When False the guideline character is repeated for the width of the table. seps refers to characters placed between heading and cell columns in the table.

MonoTable.guideline_chars = '---'

String of 0 to 3 characters to specify guideline appearance.

The first character is used for the top guideline. The second and third characters are used for the heading guideline and bottom guideline. If the character is a space the guideline is omitted. The empty string suppresses all guidelines.

MonoTable.format_func_map = None

Adds format functions selectable by a format directive.

Dictionary of format functions keyed by name. name, when used as a format directive in a format string, selects the corresponding function from the dictionary. If a key is one of the included format directive function names like ‘boolean’, ‘mformat’, etc. the included format directive function is hidden.

MonoTable.more_marker = '...'

Inserted to indicate text has been omitted.

MonoTable.align_spec_chars = '<^>'

Three characters to indicate justification.

Applies to align_spec scanning in heading, title, and format directive strings. The first character indicates left justification. The second and third characters indicate center and right justification. Setting align_spec_chars to “” disables align_spec scanning.

MonoTable.wrap_spec_char = '='

Single character to indicate the title should be text wrapped.

Wrapping is done to the width of the table. Setting wrap_spec_char to “” disables title text wrap.

MonoTable.option_spec_delimiters = '(;)'

Three characters to enclose and separate format directives.

The first and third chars enclose the options. The second char separates individual options. Setting option_spec_delimiters to “” disables format directive scanning in format strings.

MonoTable.heading_valign = 13

Alignment used for vertical justification of a multi-line heading.

Should be one of one of Vertical Alignment Constants TOP, CENTER_TOP, CENTER_BOTTOM, or BOTTOM.

MonoTable.cell_valign = 10

Alignment used for vertical justification of a multi-line cell.

Should be one of one of Vertical Alignment Constants TOP, CENTER_TOP, CENTER_BOTTOM, or BOTTOM.

MonoTable.max_cell_height = None

Truncates multi-line cells to this height. None means unlimited.

If characters are omitted, inserts more_marker at the end of the cell. Setting max_cell_height=1 will suppress multi-line cells.

MonoTable.border_chars = '--|+='

Characters used for borders in bordered tables.

One char each: top, bottom, sides, corner, heading guideline.

MonoTable.hmargin = 1

Number of blanks inserted on each side of text between borders.

Applies to bordered tables.

MonoTable.vmargin = 0

Number of blank lines inserted above and below formatted text.

Applies to bordered tables.