Python tuple snapshot
Capture a sequence of guest names in an immutable tuple.
A simple example
tuple snapshot
- Start with Original list A, B
- Do this Copy it, then append C to the original
- Result Copy still has A, B
Syntax
tuple(draft)
Run these examples in Python
Save one example at a time as lesson.py. Use Python 3.9 or later.
python3 lesson.pyFreeze the guest list used to print badges
A school prints badges from a draft guest list. A late guest joins after printing starts, so the team keeps a snapshot that records exactly how many badges belonged to the original run.
draft = ["Mira", "Sam"]
printed = tuple(draft)
draft.append("Nia")
print(len(printed))
2
The tuple retains the two original names.
Freeze the morning guest list
The school prints the first two names before a late guest registers. After saving a snapshot, add the late entry only to the working list. Which names remain visible on the snapshot?
Save a stage checklist
A technician archives the checklist before adding a new microphone. After saving a snapshot, add the late entry only to the working list. Which names remain visible on the snapshot?
What to watch for
The snapshot is shallow, so mutable objects inside the sequence can still change.