Not being a Python guru I scratched my head then searched the web.
The tricky part I think is that "response" is a generator, which you can iterate over as your code does. But for a given generator the length might not be known a-priori, so to implement len() might mean iterating over the generator and storing each result in memory in case you then do want to iterate over it. That could consume a lot of memory in some circumstances.
For a modest sized HTTP GET response it wouldn't, and there are hints here and there about libraries/modules that can do such counting for you, but bare-bones if you have a generator, you don't get len() as you would for say, an array because it might be too expensive to implement.
This section of the Python documentation looks to cover the idea:
https://wiki.python.org/moin/Generators
That's my best understanding currently; errors and omissions excepted.
I managed to obtain some useful data on time-outs before the start of round 4 in TMCL. Not as polished as I'd like but I can clean up & prettify the HTML later.
I've spent most of the past week, on & off, working through your version & reading up on the python doc's website. Heavy going at times for an amateur! When I first looked, I didn't understand much of your coding at all & I've noticed before that people who code for a living have very different style & methods to those of us who just 'tinker' about.
In the end I found it easier to start from scratch & code in my own way & the style with which I'm comfortable. It then turned out to be much easier than I expected.
The one part of your code I might have found most useful is the actual 'requests' block but I couldn't get it to work on my version. I spent a few hours trying to download the Requests module, getting nowhere. I remember reading somewhere that the download was suitable for python 3.4 to 3.6 which might be the problem because mine is 3.3.
In the end I used a section of code I found on Stackoverflow but what troubles me is that I don't fully understand what it's doing, beyond requesting/fetching the data from the server. It's this:-
.......
import json
from urllib.request import urlopen
.......
with urlopen(url) as response:
____for line in response:
________line = line.decode('utf-8') # Decoding the binary data to text.
url is of the form: 'https://api.chess.com/pub/match/' + match_id
Then I use the json parser to convert the data held in 'line' to a form that can be stored directly in a python dictionary & that part I understand. What puzzles me is what the variable 'response' is doing. It looks like a string or list but when I try len(response), all I get is an error message.
Any ideas?
What I did find most useful from your script was the try/except technique for capturing errors although I haven't used it in my own script, yet anyway. Up till now exceptions haven't been a problem for me because everything I've attempted has been very defined & strictly within my own device, so not much scope for things to go wrong, beyond my own silly coding mistakes of course.