try:
    with open('filename') as f:
        do_stuff_that_depends_on_the_existence_of_the_file(f)
except IOError as e:
    print('Trouble opening file')
How does using the try statement avoid a race condition?