Merge pull request #1958 from rowillia/master

Remove implementation of `__getslice__`
This commit is contained in:
Bruno Oliveira 2016-09-24 08:39:58 -03:00 committed by GitHub
commit 09bcf7f170
1 changed files with 3 additions and 6 deletions

View File

@ -60,16 +60,13 @@ class Source(object):
else: else:
if key.step not in (None, 1): if key.step not in (None, 1):
raise IndexError("cannot slice a Source with a step") raise IndexError("cannot slice a Source with a step")
return self.__getslice__(key.start, key.stop) newsource = Source()
newsource.lines = self.lines[key.start:key.stop]
return newsource
def __len__(self): def __len__(self):
return len(self.lines) return len(self.lines)
def __getslice__(self, start, end):
newsource = Source()
newsource.lines = self.lines[start:end]
return newsource
def strip(self): def strip(self):
""" return new source object with trailing """ return new source object with trailing
and leading blank lines removed. and leading blank lines removed.