Modifying a built-in function for logging purposes

qwweeeit at yahoo.it qwweeeit at yahoo.it
Sun May 15 05:11:31 EDT 2005


Hi Robert,
> Short answer: if you don't know stuff like this, then you probably
> shouldn't mess around with the builtins in production code.
I begin to be fed up of beeing treated as a child who is only able to
make damages...
But this time you are right...
So let's change point of view: instead of trying to modify built-in
functions, it is better to write a small wrapper of the application you
want to log.
For example:
# app_wrapper.py
...insert here the excellent routine of Fredrik Lundh (thank you
Fredrik for your contribution!)
import app    #name of the application to be logged.
In the test I carried on the answer was:
OPEN ('pippo2',) FROM ? IN /home/qwweeeit/app.py
OPEN ('pippo3', 'w') FROM ? IN /home/qwweeeit/app.py
OPEN ('pippolong', 'w') FROM ? IN /home/qwweeeit/app.py
I have not tested yet if multi-module applications answer in terms of
modules.
I must thank also Bengt Richter, also if his suggestion is far too
complicate for me...
Concerning his second replay and the virtualization of file system
access (or the usage of an external tool as suggested by Fredrik), I
leave the matter to the experts.
Bye.




More information about the Python-list mailing list