MCPcopy Index your code
hub / github.com/ipython/ipython / lookup

Method lookup

IPython/core/formatters.py:435–456  ·  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 not been

(self, obj)

Source from the content-addressed store, hash-verified

433 )
434
435 def lookup(self, obj):
436 """Look up the formatter for a given instance.
437
438 Parameters
439 ----------
440 obj : object instance
441
442 Returns
443 -------
444 f : callable
445 The registered formatting callable for the type.
446
447 Raises
448 ------
449 KeyError if the type has not been registered.
450 """
451 # look for singleton first
452 obj_id = id(obj)
453 if obj_id in self.singleton_printers:
454 return self.singleton_printers[obj_id]
455 # then lookup by type
456 return self.lookup_by_type(_get_type(obj))
457
458 def lookup_by_type(self, typ):
459 """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_matcherMethod · 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