D'Arcy Cain <da...@vybenetworks.com> writes: > On 2019-06-10 10:48, Michael Torrie wrote: > > fd = open("file","w+") > > with fd: > > There is still a small window there if there are asynchronous events > happening. Use this instead: > > with open("file","w+") as fd:
That makes the window smaller, but it doesn't actually eliminate it. Look at the generated byte code. In both cases the call to open() is over and the open file is created _before_ the SETUP_WITH instruction is executed. -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list