This is a development version (9.14.0.dev) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.14.0.dev / IPython / core / formatters / BaseFormatter

MetaHasTraits

IPython.core.formatters:BaseFormatter

source: /IPython/core/formatters.py :348

Signature

def   BaseFormatter ( ** kwargs : t.Any )  →  None

Members

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_printers and deferred_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