You are viewing an older version (9.3.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.3.0 / IPython / core / formatters / DisplayFormatter / format

function

IPython.core.formatters:DisplayFormatter.format

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

Signature

def   format ( self obj include = None exclude = None )

Summary

Return a format data dict for an object.

Extended Summary

By default all format types will be computed.

The following MIME types are usually implemented:

  • text/plain

  • text/html

  • text/markdown

  • text/latex

  • application/json

  • application/javascript

  • application/pdf

  • image/png

  • image/jpeg

  • image/svg+xml

Parameters

obj : object

The Python object whose format data will be computed.

include : list, tuple or set; optional

A list of format type strings (MIME types) to include in the format data dict. If this is set only the format types included in this list will be computed.

exclude : list, tuple or set; optional

A list of format type string (MIME types) to exclude in the format data dict. If this is set all format types will be computed, except for those included in this argument. Mimetypes present in exclude will take precedence over the ones in include

Returns

(format_dict, metadata_dict) : tuple of two dicts

format_dict is a dictionary of key/value pairs, one of each format that was generated for the object. The keys are the format types, which will usually be MIME type strings and the values and JSON'able data structure containing the raw data for the representation in that format.

metadata_dict is a dictionary of metadata about each mime-type output. Its keys will be a strict subset of the keys in format_dict.

Notes

If an object implement _repr_mimebundle_ as well as various _repr_*_, the data returned by _repr_mimebundle_ will take precedence and the corresponding _repr_*_ for this mimetype will not be called.

Aliases

  • IPython.core.formatters.DisplayFormatter.format