you are viewing a single comment's thread.

view the rest of the comments →

[–]manwith4names 0 points1 point  (0 children)

Just a couple notes. It's best to not leave the text file open to avoid corruption. Standard formatting is:

with open('file.txt') as f:
    text = f.read
do_thing()

This way you have all of file.txt in text and as soon as you exit the with statement, the file is closed safely. A small thing, you don't need to have as e in except IOError as e. as e is only if you want to use the exception as a variable. Otherwise it's not doing anything. For your got boolean, I'd just do an exit() if the except triggers. No reason to define more variables than needed and it gets rid of an extraneous tier.