← Lesson
Useful Standard Library
Joeven
Run
Reset
Python loads on first run
from datetime import datetime, timezone, timedelta from collections import Counter, defaultdict from itertools import islice import hashlib import uuid import copy import time now = datetime.now(timezone.utc) print("now", now.isoformat()) print("later", (now + timedelta(minutes=2)).isoformat()) tools = ["search", "read", "search", "search"] print("counts", Counter(tools)) grouped = defaultdict(list) for name in tools: grouped[name].append("ok") print("grouped", dict(grouped)) print("first 3", list(islice(tools, 3))) digest = hashlib.sha256(b"hello").hexdigest() print("sha256", digest[:16]) print("run_id", str(uuid.uuid4())) original = {"nested": {"n": 1}} shallow = copy.copy(original) deep = copy.deepcopy(original) shallow["nested"]["n"] = 2 print("after shallow copy, original", original["nested"]["n"]) print("deepcopy stayed", deep["nested"]["n"]) # time.sleep(5) # do not: this blocks and would freeze the page print("sleep skipped; clock", time.time())
Run to execute this in your browser. Nothing is sent to a server.