From: reiv Date: Sat, 17 Oct 2015 20:36:08 +0000 (+0200) Subject: Simplify with itertools.islice(). X-Git-Url: http://git.oshgnacknak.de/?a=commitdiff_plain;h=b54b08c91bb7f59a9ea720abbf944809d1ea8956;p=youtube-dl Simplify with itertools.islice(). --- diff --git a/youtube_dl/extractor/soundcloud.py b/youtube_dl/extractor/soundcloud.py index 3fe991849..959f27975 100644 --- a/youtube_dl/extractor/soundcloud.py +++ b/youtube_dl/extractor/soundcloud.py @@ -532,11 +532,7 @@ class SoundcloudSearchIE(SearchInfoExtractor, SoundcloudIE): collection_id='Query "{0}"'.format(query), q=query.encode('utf-8')) - for _ in range(n): - try: - track = next(tracks) - except StopIteration: - break + for track in itertools.islice(tracks, n): uri = track['uri'] title = track['title'] results.append(self.url_result(url=uri))