Issue
When I create an unbound super
object, IPython
displays it as <super: None, None>
. Yet both str(...)
and repr(...)
, as well as the interactive ordinary Python interpreter, display it as <super: <class 'object'>, NULL>
, which is more informative. I know that IPythons displayhook is different from the default Python displayhook, but does this difference explain the different representations? Where does IPython
get its display for builtin objects from?
In ipython3
:
In [1]: super(object)
Out[1]: <super: None, None>
In [2]: str(_1), repr(_1)
Out[2]: ("<super: <class 'object'>, NULL>", "<super: <class 'object'>, NULL>")
In python3.3
:
>>> super(object)
<super: <class 'object'>, NULL>
>>> from IPython.core import displayhook, interactiveshell
>>> print(displayhook.DisplayHook(interactiveshell.InteractiveShell()).compute_format_data(super(object)))
WARNING: IPython History requires SQLite, your history will not be saved
({'text/plain': '<super: None, None>'}, {})
What's going on?
Solution
Well spotted, thanks. This was a bug in IPython, and I've just made this pull request to fix it.
IPython calculates representations of a number of builtin types in IPython.lib.pretty
. This is useful for things like compiled regex patterns, where the default repr is just <_sre.SRE_Pattern object at 0x7f...
.
Answered By - Thomas K
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.