[Tutor] Olle-Olla
Kent Johnson
kent37 at tds.net
Tue Apr 18 20:59:38 CEST 2006
Andre Engels wrote:
> 2006/4/18, Kent Johnson <kent37 at tds.net>:
>> János Juhász wrote:
>>> Hi All,
>>>
>>> Is it possible to replace the print statement with one of mine function ?
>>>
>>> In reality, I would like to replace the print in my PyCrust app with the
>>> log.write() function.
>> Best: Use a good editor to change your print statements to log.write()
>
> Even better: Use a good editor to change your print statements to
> myprint() and then def myprint() to be log.write(). This has the
> advantage that if (for example) you want prints later to be "usually
> log.write() but if redFlagHighestWarning is True, then both
> log.write() and print()", you don't need to go through all this again,
> but just have to change myprint().
Or use the logging module, which lets you make changes like this by
editing a config file. I usually set it up so that INFO level and higher
messages go to a console or GUI panel, and all messages go to a rollover
file. Very handy.
Kent
More information about the Tutor
mailing list