MCPcopy Create free account
hub / github.com/ipython/ipython / __call__

Method __call__

IPython/core/formatters.py:950–973  ·  view source on GitHub ↗

Compute the format for an object. Identical to parent's method but we pass extra parameters to the method. Unlike other _repr_*_ `_repr_mimebundle_` should allow extra kwargs, in particular `include` and `exclude`.

(self, obj, include=None, exclude=None)

Source from the content-addressed store, hash-verified

948
949 @catch_format_error
950 def __call__(self, obj, include=None, exclude=None):
951 """Compute the format for an object.
952
953 Identical to parent's method but we pass extra parameters to the method.
954
955 Unlike other _repr_*_ `_repr_mimebundle_` should allow extra kwargs, in
956 particular `include` and `exclude`.
957 """
958 if self.enabled:
959 # lookup registered printer
960 try:
961 printer = self.lookup(obj)
962 except KeyError:
963 pass
964 else:
965 return printer(obj)
966 # Finally look for special method names
967 method = get_real_method(obj, self.print_method)
968
969 if method is not None:
970 return method(include=include, exclude=exclude)
971 return None
972 else:
973 return None
974
975
976FormatterABC.register(BaseFormatter)

Callers

nothing calls this directly

Calls 2

get_real_methodFunction · 0.85
lookupMethod · 0.80

Tested by

no test coverage detected