Class StopIteration
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Python's StopIteration: an iterator has no more items. A generator's return value travels in it as
value, which is how Python's yield from receives a sub-generator's result.
public class StopIteration : NumSharpException, ISerializable, INumSharpException
- Inheritance
-
StopIteration
- Implements
- Inherited Members
Remarks
It derives from NumSharpException: .NET has no exception with the same meaning (an
IEnumerator ends by returning false from MoveNext, and NumSharp's
iterators — np.nditer, np.ndindex, flatiter — are .NET enumerables that end the same way).
NumSharp never raises it; the class exists so a port of code that drives an iterator by hand
(next(it) until StopIteration) compiles and behaves as in Python.
Constructors
StopIteration()
Creates the error with Python's text for a bare raise StopIteration: an empty
Message and a null value, as str(StopIteration()) is ''
and its value is None.
public StopIteration()
StopIteration(object)
Python's StopIteration(value): a generator's return value. The message is Python's str(value)
(5, 1.5, True, None).
public StopIteration(object value)
Parameters
valueobjectThe value, or null for
None.
Exceptions
- ValueError
valueis a Python int (BigInteger) of more than 4300 decimal digits, whosestr()CPython refuses.
StopIteration(string)
Python's StopIteration(text): the text is both the message and value.
public StopIteration(string message)
Parameters
messagestringThe text, or null for Python's
StopIteration(None)(whose message isNoneand value null).
Remarks
Python keeps a lone argument as value whatever it is; a string argument binds here, any other
value to StopIteration(object), with the same result.
StopIteration(string, Exception)
Creates the error with a message and the exception that caused it: Python's raise StopIteration(message)
from innerException, the cause kept in InnerException; the message is also
value.
public StopIteration(string message, Exception innerException)
Parameters
messagestringThe text, verbatim.
innerExceptionExceptionThe exception that led to this one, or null for none.
Properties
value
The iterator's final value (Python's value): the constructor's argument, or null after the bare
constructor (Python's None).
public object value { get; }