I am reading lines from a serial connection (pyserial), at the moment I am using a while loop to read a line, and then I perform a number of functions on this input and then store them in an object (rangefinder).
It was mentioned that I should consider sequential input as a generator, since this is done in python.
Does anyone have any experience? Or at least explain in principle how this will be achieved?
Why is it better? Is it purely for memory / speed?
EDIT:
where is the function:
at_end()
have come? I get:
AttributeError: 'Serial' object has no attribute 'at_end'
If i use
while True:
yield source.readline()
then I get the output.
source
share