summaryrefslogtreecommitdiffstats
path: root/FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-01-23 14:28:53 -0800
committeryum <yum.food.vr@gmail.com>2023-01-23 14:32:09 -0800
commit9fff496394dcd94c4084694ca96a5e07ab836274 (patch)
treed89b78e16ecb6011bdd74555da79f7a8c1d90752 /FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py
parent9329d64f991b8b3289af22e4c2eedb09a97c5640 (diff)
package.ps1 now fetches all dependencies
Don't literally check in Python since it looks dodgy (rightfully so). Instead the build script just fetches it. * Update README, simplifying language and documenting other projects
Diffstat (limited to 'FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py')
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py b/FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py
deleted file mode 100644
index 097638a..0000000
--- a/FOSS/Python/Dependencies/future-0.18.2/src/future/builtins/newnext.py
+++ /dev/null
@@ -1,70 +0,0 @@
-'''
-This module provides a newnext() function in Python 2 that mimics the
-behaviour of ``next()`` in Python 3, falling back to Python 2's behaviour for
-compatibility if this fails.
-
-``newnext(iterator)`` calls the iterator's ``__next__()`` method if it exists. If this
-doesn't exist, it falls back to calling a ``next()`` method.
-
-For example:
-
- >>> class Odds(object):
- ... def __init__(self, start=1):
- ... self.value = start - 2
- ... def __next__(self): # note the Py3 interface
- ... self.value += 2
- ... return self.value
- ... def __iter__(self):
- ... return self
- ...
- >>> iterator = Odds()
- >>> next(iterator)
- 1
- >>> next(iterator)
- 3
-
-If you are defining your own custom iterator class as above, it is preferable
-to explicitly decorate the class with the @implements_iterator decorator from
-``future.utils`` as follows:
-
- >>> @implements_iterator
- ... class Odds(object):
- ... # etc
- ... pass
-
-This next() function is primarily for consuming iterators defined in Python 3
-code elsewhere that we would like to run on Python 2 or 3.
-'''
-
-_builtin_next = next
-
-_SENTINEL = object()
-
-def newnext(iterator, default=_SENTINEL):
- """
- next(iterator[, default])
-
- Return the next item from the iterator. If default is given and the iterator
- is exhausted, it is returned instead of raising StopIteration.
- """
-
- # args = []
- # if default is not _SENTINEL:
- # args.append(default)
- try:
- try:
- return iterator.__next__()
- except AttributeError:
- try:
- return iterator.next()
- except AttributeError:
- raise TypeError("'{0}' object is not an iterator".format(
- iterator.__class__.__name__))
- except StopIteration as e:
- if default is _SENTINEL:
- raise e
- else:
- return default
-
-
-__all__ = ['newnext']