← Lesson
Read vs Write Tools
Joeven
Run
Reset
Python loads on first run
TICKETS = {"9182": {"title": "Runner OOM", "state": "open"}} MAIL = [] def get_ticket(ticket_id): row = TICKETS.get(ticket_id) if row is None: return {"error": "not_found"} return {"ok": True, "ticket": dict(row)} def close_ticket(ticket_id): row = TICKETS.get(ticket_id) if row is None: return {"error": "not_found"} row["state"] = "closed" return {"ok": True, "ticket_id": ticket_id, "state": "closed"} def send_mail(to, body): MAIL.append({"to": to, "body": body}) return {"ok": True, "n": len(MAIL)} print("read", get_ticket("9182")) print("still open", TICKETS["9182"]["state"]) print("write", close_ticket("9182")) print("now", TICKETS["9182"]["state"]) print("mail", send_mail("ada@example.com", "closed")) print("mail again", send_mail("ada@example.com", "closed"), "count", len(MAIL))
Run to execute this in your browser. Nothing is sent to a server.