Shallow copy, deep copy, and the nested-dict bug — step 6 of 9
Claude wrote a "make a backup before editing" snippet. The bug: it used
.copy() on a nested dict. When the script edits the backup's nested
tags list, the original list also changes.
The expected output is:
original tags: ['admin']
backup tags: ['admin', 'temp']
Right now it's:
original tags: ['admin', 'temp']
backup tags: ['admin', 'temp']
Fix line 5 so the backup is truly independent. The copy module is already
imported on line 1.
The break is on line 5 — but read the whole snippet first.
⌘↵ runs the editor.read, then continue.
Claude wrote a "make a backup before editing" snippet. The bug: it used
.copy() on a nested dict. When the script edits the backup's nested
tags list, the original list also changes.
The expected output is:
original tags: ['admin']
backup tags: ['admin', 'temp']
Right now it's:
original tags: ['admin', 'temp']
backup tags: ['admin', 'temp']
Fix line 5 so the backup is truly independent. The copy module is already
imported on line 1.
The break is on line 5 — but read the whole snippet first.
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.