On Wed, Feb 27, 2019 at 9:00 AM Marko Rauhamaa <ma...@pacujo.net> wrote: > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release the file lock) before/while do_stuff() is > executed? > > I couldn't find an immediate answer in the documentation.
The variable is alive, so the object is alive. Common sense should make this clear, but there's probably some details in the documentation if you actually need a citation. The name "f" is part of the function's locals until that function returns or the name is explicitly unbound. ChrisA -- https://mail.python.org/mailman/listinfo/python-list