I cant find low level explanation for what stream exactly is in order to understand how it relates to iterators and other key concepts in Python.
For example iterators are defines as:
"An iterator is an object representing a stream of data; this object returns the data one element at a time. A Python iterator must support a method called next() that takes no arguments and always returns the next element of the stream."
What exactly is meant by iterator representing a stream? For example if we iterate over list with for loop like this:
list= [1,2,3,4,5]
for number in list:
print(number)
Is iterator number a stream if we look as containing method next(). Or is it a stream because it both uses next() and contains data from source. Therefore is stream simply a flow of data from source the method next() or is stream both flow of data and storing of said data in iterator object and then using it? But it seems to be neither since : "A Python iterator must support a method called next() that takes no arguments and always returns the next element of the stream".
Then what exactly is stream if next() which allows flow of data from source is said to return next element of stream? But isnt it itself a stream? This makes stream sound like source itself original data (a list in this instance or file in some other instance) is stream from which next gets elements. What exactly is stream then? Im really confused by this.
Another example are file objects. They are called streams too. Are they then iterators in some way also? But what are then readers like csv.reader which itself read lines from file. Shouldn't they be considered streams since data flows through them into program file?
Hopefully someone can help me understand this concept because it seems crucial and i dont seem to understand it correctly.