As a revision of my initial question, when we look at next_block(), it's documented as follows:
############################################ def next_block(the_file): """Return the next block of data from the trivia file.""" .... ############################################ What if there are no more blocks in the file? What should happen then? Let's say that we do a test, where we pass in the empty file to next_block(). ###################### from io import StringIO x = next_block(StringIO('')) ###################### What do you want to happen in this situation? --- As a side note: if you have control over the data format, you might want to consider using JSON rather than a line-based format. If you use JSON, this takes care of a few issues that you are working around now. For example, you can reuse the newline escapes rather than define your own convention. Also, rather than read a stream of records, where you have to deal with the end of the file, you might just read one JSON object that represents your whole trivia file, which will simplify your program's logic. See: https://docs.python.org/2/library/json.html and use your favorite web search engine for 'json python tutorial', and you should be able to find some useful information. If you have questions, please feel free to ask. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor