There's no need to explicitly raise StopIteration as that's what a bare return statement does for a generator function - so yes they're the same.
As of late 2014 return is correct and raise StopIteration for ending a generator is on a depreciation schedule. See PEP 479 for full details.
https://stackoverflow.com/q/14183803/248296
https://www.python.org/dev/peps/pep-0479/
This commit is contained in:
Victor 2017-09-14 20:31:50 +03:00
parent bf30aba005
commit 806a80cef1

View File

@ -92,7 +92,7 @@ class QuerySet(BaseQuerySet):
# Raise StopIteration if we already established there were no more # Raise StopIteration if we already established there were no more
# docs in the db cursor. # docs in the db cursor.
if not self._has_more: if not self._has_more:
raise StopIteration return
# Otherwise, populate more of the cache and repeat. # Otherwise, populate more of the cache and repeat.
if len(self._result_cache) <= pos: if len(self._result_cache) <= pos: