def prepend(self, container):
"""Insert objects at the start of the container"""
if not isinstance(container, collections.MutableSequence):
container = [container]
container.reverse()
for x in container:
if self._current != x:
try:
self._container.remove(x)
except ValueError:
pass
self._container.appendleft(x)
try:
self._container.remove(self._current)
self._container.appendleft(self._current)
except ValueError:
pass
if self._current is None and any(self._container):
self._current = self._container[0]
评论列表
文章目录