# Dictionary, iterate & update objects

**URL:** <https://www.ruby-forum.com/t/dictionary-iterate-update-objects/79592>\
**Category:** Ruby\
**Created:** [December 16, 2006, 9:56pm UTC](https://www.ruby-forum.com/t/dictionary-iterate-update-objects/79592 "2006-12-16T21:56:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jansenh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@jansenh](https://www.ruby-forum.com/u/jansenh)\
**Post date:** [December 16, 2006, 9:56pm UTC](https://www.ruby-forum.com/t/dictionary-iterate-update-objects/79592/1 "2006-12-16T21:56:59Z")

</div>

hi comp.lang.python.

I need some newbe advice on idiomatic use of Python dictionaries.

I have service with a dictionary which holds a bunch of objects as  
values, and an ID as key to each object. Then I want to change an  
objects state based on its key. The way I am doing this now is by using  
‘fromkeys’ and copying my object over in a temporary dictionary, then  
manipulating the object, and then I do an ‘update’ back to the main  
dictionary… :-0

There has to be a smarter way? Thankful for any piece of  
enlightenment…

regards, Henning

---

<div class="post-metadata">

**Author:** ![jansenh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@jansenh](https://www.ruby-forum.com/u/jansenh)\
**Post date:** [December 16, 2006, 9:59pm UTC](https://www.ruby-forum.com/t/dictionary-iterate-update-objects/79592/2 "2006-12-16T21:59:00Z")

</div>

jansenh wrote:

> hi comp.lang.python.

Erroneous crosspost?

David V.

---

<div class="post-metadata">

**Author:** ![jansenh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6f9a4e/32.png) [@jansenh](https://www.ruby-forum.com/u/jansenh)\
**Post date:** [December 16, 2006, 10:01pm UTC](https://www.ruby-forum.com/t/dictionary-iterate-update-objects/79592/3 "2006-12-16T22:01:00Z")

</div>

oops! This one was actually meant to be posted in the PYTHON group …  
☹ Sorry!

regards, Henning
