Fix getting individual items from KeySequence

This commit is contained in:
Florian Bruhin 2018-02-26 20:48:11 +01:00
parent 9f0e1a98a0
commit e9d58dae2a

View File

@ -324,8 +324,12 @@ class KeySequence:
return sum(len(seq) for seq in self._sequences)
def __getitem__(self, item):
keys = list(self._iter_keys())
return self.__class__(*keys[item])
if isinstance(item, slice):
keys = list(self._iter_keys())
return self.__class__(*keys[item])
else:
infos = list(self)
return infos[item]
def _iter_keys(self):
return itertools.chain.from_iterable(self._sequences)