Hooking file open

Farshid Lashkari no at spam.com
Wed Nov 1 16:21:20 EST 2006


Dale Strickland-Clark wrote:
> You might consider trapping calls to file() too, which is an alias for
> open().

Thanks, I didn't know about that.

> Also, I think I'd do my logging before calling the real function. It depends
> how you want to deal with exceptions. 

I placed the logging after the call to the real function so that files 
that don't exist will not be logged. However, I'm already checking for 
file existence during the post process of the script running, so I guess 
it doesn't really make too much of a difference.

Thanks for the help.

-Farshid



More information about the Python-list mailing list