>>> class x(file): pass >>> y=x('morethreading.py') >>> y.foo=y >>> y=None >>> In the slightly more general case, when (if ever) can the interpretter prove that it is safe to close that file? Will the file be closed?