mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
17 lines
437 B
Python
17 lines
437 B
Python
|
|
# python2.5 compatibility
|
|
try:
|
|
next = next
|
|
except NameError:
|
|
_raiseStopIteration = object()
|
|
def next(iterator, default=_raiseStopIteration):
|
|
if not hasattr(iterator, 'next'):
|
|
raise TypeError("not an iterator")
|
|
try:
|
|
return iterator.next()
|
|
except StopIteration:
|
|
if default is _raiseStopIteration:
|
|
raise
|
|
else:
|
|
return default
|