https://bugzilla.wikimedia.org/show_bug.cgi?id=68705
--- Comment #6 from John Mark Vandenberg jayvdb@gmail.com --- (In reply to Fabian from comment #5)
The for-else does not differ between an empty list and a non empty.
This will work
for i, page in enumerate(generator, 1): .... else: if 'i' not in locals(): ...
(I dont like locals() being used)
There are many other ways to do it, including wrapping the generator in a generator class that allows peaking.