Why isn't __add__ implemented in Python's deque?

社会主义新天地 提交于 2021-02-07 19:04:57

问题


Concatenating two deques results in a TypeError.

from collections import deque
q = deque()
q + q

But __iadd__ is implemented so += is supported.

q1 = deque([1])
q2 = deque([2])
q1 += q2

What is the reason that only __iadd__ get implemented?


回答1:


This is a bug which is already fixed in the repos, so it should be included in the next released version of Python (3.5).



来源:https://stackoverflow.com/questions/32547316/why-isnt-add-implemented-in-pythons-deque

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!