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

Method lookup

IPython/core/formatters.py:374–395  ·  view source on GitHub ↗

Look up the formatter for a given instance. Parameters ---------- obj : object instance Returns ------- f : callable The registered formatting callable for the type. Raises ------ KeyError if the type has

(self, obj)

Source from the content-addressed store, hash-verified

372 )
373
374 def lookup(self, obj):
375 """Look up the formatter for a given instance.
376
377 Parameters
378 ----------
379 obj : object instance
380
381 Returns
382 -------
383 f : callable
384 The registered formatting callable for the type.
385
386 Raises
387 ------
388 KeyError if the type has not been registered.
389 """
390 # look for singleton first
391 obj_id = id(obj)
392 if obj_id in self.singleton_printers:
393 return self.singleton_printers[obj_id]
394 # then lookup by type
395 return self.lookup_by_type(_get_type(obj))
396
397 def lookup_by_type(self, typ):
398 """Look up the registered formatter for a type.

Callers 7

__call__Method · 0.95
formatMethod · 0.80
__call__Method · 0.80
__call__Method · 0.80
unicode_name_matchesMethod · 0.80
test_lookupFunction · 0.80
test_lookup_stringFunction · 0.80

Calls 2

lookup_by_typeMethod · 0.95
_get_typeFunction · 0.85

Tested by 2

test_lookupFunction · 0.64
test_lookup_stringFunction · 0.64