Rewrite the next function.
This commit is contained in:
1 parent
da1a163da7
commit
7607db801f
4 files changed
+22
-12
No files matched your search
@@ -6,17 +6,6 @@ possible for the auto completion.
|
||||
"""
|
||||
|
||||
|
||||
def next(iterator, default=None):
|
||||
if random.choice([0, 1]):
|
||||
if hasattr("next"):
|
||||
return iterator.next()
|
||||
else:
|
||||
return iterator.__next__()
|
||||
else:
|
||||
if default is not None:
|
||||
return default
|
||||
|
||||
|
||||
def iter(collection, sentinel=None):
|
||||
if sentinel:
|
||||
yield collection()
|
||||
|
||||
Reference in new issue
Block a user