Python: Append to list owned by an instance stored in shelved dictionary
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Python: Append To List Owned By An Instance Stored In Shelved Dictionary
01:40 Answer 1 Score 0
02:07 Accepted Answer Score 1
02:29 Thank you
--
Full question
https://stackoverflow.com/questions/3014...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #list #instances #shelve
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Python: Append To List Owned By An Instance Stored In Shelved Dictionary
01:40 Answer 1 Score 0
02:07 Accepted Answer Score 1
02:29 Thank you
--
Full question
https://stackoverflow.com/questions/3014...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #list #instances #shelve
#avk47
ACCEPTED ANSWER
Score 1
You need to extract, mutate and store the object back in the shelf to persist it.
e.g
# extract
this_friend = shelf[full_name]
# mutate
this_friend.add_timestamp(now)
# re-add
shelf[full_name] = this_friend
shelf.close()
You can see an example of this in the python docs.
The other option is pass the writeback parameter as True to shelve.open and it will allow you to write to the keys directly. 
ANSWER 2
Score 0
@paulrooney answered this.
Objects in the shelf need to be removed from the shelf, assigned to a name, mutated (to add time stamp), then put back in the shelf. This code works fine.
shelf = shelve.open('/Users/Perrin/Library/Scripts/friend_shelf.db')
if full_name in shelf:
    this_friend = shelf[full_name]
    this_friend.add_timestamp(now)
    shelf[full_name] = this_friend
    print shelf[full_name].timestamps
    shelf.close
else:
    shelf[full_name] = Friend(full_name)
    this_friend = shelf[full_name]
    this_friend.add_timestamp(now)
    shelf[full_name] = this_friend
    shelf.close