Understanding the flush

Report a typo

Here's a program to tangle you a little:

f1 = open('one.txt', 'w')
f2 = open('two.txt', 'w')
f3 = open('three.txt', 'w')

print('start', 'end', sep=' & ', file=f1)  # [1]
print('start', file=f2, flush=True)
f3.write('end')                            # [2]
print('end', file=f2, flush=True)          # [3]

f1.close()                                 # [4]
f2.close()                                 # [5]
f3.close()                                 # [6]

At which point will the string 'end' appear for the first time in any of the files?

Tip: Remember what we have discussed about the moment at which files are automatically flushed in Python.

Select one option from the list
___

Create a free account to access the full topic