Skip to content

Commit

Permalink
use next() built-in to get first item of iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnboy committed May 12, 2016
1 parent bb329cf commit 25f9ef6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions assertpy/assertpy.py
Expand Up @@ -485,10 +485,9 @@ def starts_with(self, prefix):
elif isinstance(self.val, collections.Iterable):
if len(self.val) == 0:
raise ValueError('val must not be empty')
for i in self.val:
if i != prefix:
self._err('Expected %s to start with <%s>, but did not.' % (self.val, prefix))
break
first = next(i for i in self.val)
if first != prefix:
self._err('Expected %s to start with <%s>, but did not.' % (self.val, prefix))
else:
raise TypeError('val is not a string or iterable')
return self
Expand Down

0 comments on commit 25f9ef6

Please sign in to comment.