为了回应我的a previous question,我现在想知道有什么方法可以使下面的代码看起来更好:
class Cycle(list):
def insertextend(self, index, other, reverse = False):
"""Extend the cycle by inserting an iterable at the given position."""
index %= len(self)
if reverse:
super(Cycle, self).__init__(self[:index] + list(reversed(other)) + self[index:])
else:
super(Cycle, self).__init__(self[:index] + other + self[index:])
关于如何移除super(Cycle, self).__init__(...)
?
答案 0 :(得分:0)
def insertextend(self, index, other, reverse = False):
"""Extend the cycle by inserting an iterable at the given position."""
index %= len(self)
if reverse: other = reversed(other)
self[index:index] = other