##// END OF EJS Templates
Merge pull request #4760 from takluyver/examples-py3compat...
Merge pull request #4760 from takluyver/examples-py3compat Make examples and docs more Python 3 aware

File last commit:

r13789:68df9a45
r14082:608fd030 merge
Show More
formatters.txt
20 lines | 845 B | text/plain | TextLexer
DisplayFormatter changes
========================
There was no official way to query or remove callbacks in the Formatter API.
To remedy this, the following methods are added to :class:`BaseFormatter`:
- ``lookup(instance)`` - return appropriate callback or a given object
- ``lookup_by_type(type_or_str)`` - return appropriate callback for a given type or ``'mod.name'`` type string
- ``pop(type_or_str)`` - remove a type (by type or string).
Pass a second argument to avoid KeyError (like dict).
All of the above methods raise a KeyError if no match is found.
And the following methods are changed:
- ``for_type(type_or_str)`` - behaves the same as before, only adding support for ``'mod.name'``
type strings in addition to plain types. This removes the need for ``for_type_by_name()``,
but it remains for backward compatibility.