Scanning a file

Paul Watson pwatson at redlinepy.com
Mon Oct 31 15:13:26 CET 2005


Alex Martelli wrote:
...
>>>>gc.garbage
> 
> [<__main__.a object at 0x64cf0>, <__main__.b object at 0x58510>]
> 
> So, no big deal -- run a gc.collect() and parse through gc.garbage for
> any instances of your "wrapper of file" class, and you'll find ones that
> were forgotten as part of a cyclic garbage loop and you can check
> whether they were explicitly closed or not.
> 
> 
> Alex

Since everyone needs this, how about building it in such that files 
which are closed by the runtime, and not user code, are reported or 
queryable?  Perhaps a command line switch to either invoke or suppress 
reporting them on exit.

Is there any facility for another program to peer into the state of a 
Python program?  Would this be a security problem?



More information about the Python-list mailing list