[Tutor] Please help disentangle my program logic

Robert Alexander gogonegro at gmail.com
Sun Jan 5 13:37:18 EST 2020


That makes a lot of sense.

I already have such situation.

My program currently handles an “exception” and exits if a prerequisite
external program is not found. So that would go to STDOUT/ERR and the logs
proper to a log via the logging module.

Excellent suggestion.

Thanks a lot.

Robert

On 5 January 2020 at 19:34:51, Mats Wichmann (mats at wichmann.us) wrote:

On 1/5/20 11:23 AM, Robert Alexander wrote:
> Thank you Mats. Very interesting observation.
>
> May you kindly expand on why you are suggesting this?
>
> In my opinion specifying a log name at runtime gives me more flexibility
> but I might be not considering some other important reason.

Not sure I'm answering the right question here, but...

You can still specify the logging location on the command line by
accepting an argument, and having a default in the program if it's not
on the command line.

The logigng module gives you the flexibility to log to different places,
even - you can put every reading in the log, and important events (like
Internet connection is down) somewhere else - your console, sending by
email (I'm not sure that's directly supported, but wouldn't be hard to
set up), by assigning different log levels to different types of events.

>
> Ciao
>
> PS Etiquette question please: Is it better to reply to both the sender
and
> the list or the list only?
>
>
> On 5 January 2020 at 19:18:30, Mats Wichmann (mats at wichmann.us) wrote:
>

> quick reaction: look into the logging module to control how, where and
> what to log. No need to reinvent the wheel.
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list