IPython中的类实现是否相对于Python进行了修改?
我试着比较Python和IPython中的IPython中的类实现是否相对于Python进行了修改?,python,ipython,Python,Ipython,我试着比较Python和IPython中的\uuuu class\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu函数和类型()函数,并想知道下面的行为差异是否是因为IPython w 蟒蛇 >>> [].__class__ <class 'list'> >>> type([]) <class 'list'> 但对于print,它似
\uuuu class\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
函数和类型()
函数,并想知道下面的行为差异是否是因为IPython w
蟒蛇
>>> [].__class__
<class 'list'>
>>> type([])
<class 'list'>
但对于print,它似乎仍然是指Python的\uuuuu类
蟒蛇
>>> print(type([]))
<class 'list'>
打印(类型([]))
伊皮顿
In [2]: [].__class__
Out[2]: list
In [3]: type([])
Out[3]: list
In [4]: print(type([]))
<class 'list'>
[4]中的:打印(键入([]))
这就是神奇发生的地方:
In [1] import sys
In [2] sys.displayhook
Out[2]: <IPython.terminal.prompts.RichPromptDisplayHook at 0x7f6c42b08190>
[1]导入系统中的
在[2]sys.displayhook中
出[2]:
vs
导入系统
>>>sys.displayhook
正在显示的对象(
列表
,或
)是同一个对象。使用,IPython修改它在交互回复中的显示方式。我猜是IPython的sys.displayhook
被修改了:列表仍然指
,只是打印方式不同而已。
>>> import sys
>>> sys.displayhook
<built-in function displayhook>