It seems obvious to me that an Iterator object X, the methods:
X.next()python 2.xX.__next__()python 3.x
are not referentially transparent because every invocation returns a different result.
But, I just need confirmation that I am correct. Thanks.
You’re right that an iterator can return a different result on each call, so it cannot be called referentially transparent.
However, the aggregate actions of consuming an iterable can be referentially transparent eventhough the individual steps are not. For example,
list('cat')is deterministic and referentially transparent eventhough the implementation of list makes repeated next calls on the string iterator.