bundles / IPython 9.3.0 / IPython / core / formatters / BaseFormatter
MetaHasTraits
IPython.core.formatters:BaseFormatter
source: /IPython/core/formatters.py :348
Signature
def BaseFormatter ( ** kwargs : t.Any ) → None Members
-
__annotate__ -
__call__ -
__contains__ -
_check_return -
_in_deferred_types -
for_type -
for_type_by_name -
lookup -
lookup_by_type -
pop
Summary
A base formatter class that is configurable.
Extended Summary
This formatter should usually be used as the base class of all formatters. It is a traited Configurable class and includes an extensible API for users to determine how their objects are formatted. The following logic is used to find a function to format an given object.
The object is introspected to see if it has a method with the name
print_method. If is does, that object is passed to that method for formatting.If no print method is found, three internal dictionaries are consulted to find print method:
singleton_printers,type_printersanddeferred_printers.
Users should use these dictionaries to register functions that will be used to compute the format data for their objects (if those objects don't have the special print methods). The easiest way of using these dictionaries is through the for_type and for_type_by_name methods.
If no function/callable is found to compute the format data, None is returned and this format type is not used.
Aliases
-
IPython.core.formatters.BaseFormatter