A 3-step script ran for 8 seconds and produced no output. Did step 1 work? Did step 2 hang? Did everything succeed silently? Without logs, you can't tell.
print("step 1: fetching messages...")
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 5})
messages = result.get("messages", [])
print(f"step 1: got {len(messages)} messages")
print("step 2: filtering urgent...")
urgent = [m for m in messages if "urgent" in m.get("subject", "").lower()]
print(f"step 2: {len(urgent)} urgent")
print("step 3: sending alerts...")
for m in urgent:
toolset.execute_action(Action.SLACK_SEND_MESSAGE, {"channel": "#general", "text": f"Urgent: {m.get('subject','')}"})
print(f"step 3: sent {len(urgent)} alerts")Just print lines? Not a logging library?
For week 2, plain print is fine. The pattern: a before print stating intent, an after print confirming the result. Not a logging library — those introduce levels (info/warn/error) and rotation, which Auto Intermediate covers. Today's takeaway: every step boundary needs some output.
Even when nothing's broken? Doesn't it just clutter the output?
That's the trade-off. Logs you don't need until you do. The ratio you want: any time a learner asks you "why did my script do X?", the log already tells them. That's what the print lines pay for.
print("step N: <what's about to happen>")
# ... do the work ...
print(f"step N: <result, with relevant numbers>")Two prints per step:
Don't write only the after-print. The before-print is what lets you see where a hang lives.
got 5 messages, 0 matched, sent 3 alertscreated event abc-123Don't print:
raise instead — the framework handles it)Imagine waking up at 2am, your script ran a scheduled job overnight, and something's wrong. Read your logs:
step 1: fetching messages...
step 1: got 5 messages
step 2: filtering urgent...
step 2: 1 urgent
step 3: sending alerts...
No "step 3: sent 1 alerts" line. So step 3 started but didn't finish. Hung mid-loop, or the network broke. You know exactly where to look.
Now imagine the same script with no prints:
(silent)
Good luck.
A 3-step script ran for 8 seconds and produced no output. Did step 1 work? Did step 2 hang? Did everything succeed silently? Without logs, you can't tell.
print("step 1: fetching messages...")
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 5})
messages = result.get("messages", [])
print(f"step 1: got {len(messages)} messages")
print("step 2: filtering urgent...")
urgent = [m for m in messages if "urgent" in m.get("subject", "").lower()]
print(f"step 2: {len(urgent)} urgent")
print("step 3: sending alerts...")
for m in urgent:
toolset.execute_action(Action.SLACK_SEND_MESSAGE, {"channel": "#general", "text": f"Urgent: {m.get('subject','')}"})
print(f"step 3: sent {len(urgent)} alerts")Just print lines? Not a logging library?
For week 2, plain print is fine. The pattern: a before print stating intent, an after print confirming the result. Not a logging library — those introduce levels (info/warn/error) and rotation, which Auto Intermediate covers. Today's takeaway: every step boundary needs some output.
Even when nothing's broken? Doesn't it just clutter the output?
That's the trade-off. Logs you don't need until you do. The ratio you want: any time a learner asks you "why did my script do X?", the log already tells them. That's what the print lines pay for.
print("step N: <what's about to happen>")
# ... do the work ...
print(f"step N: <result, with relevant numbers>")Two prints per step:
Don't write only the after-print. The before-print is what lets you see where a hang lives.
got 5 messages, 0 matched, sent 3 alertscreated event abc-123Don't print:
raise instead — the framework handles it)Imagine waking up at 2am, your script ran a scheduled job overnight, and something's wrong. Read your logs:
step 1: fetching messages...
step 1: got 5 messages
step 2: filtering urgent...
step 2: 1 urgent
step 3: sending alerts...
No "step 3: sent 1 alerts" line. So step 3 started but didn't finish. Hung mid-loop, or the network broke. You know exactly where to look.
Now imagine the same script with no prints:
(silent)
Good luck.
Create a free account to get started. Paid plans unlock all tracks.