Question: Some stated that python dictionary is thread safe. Does it mean I can or cannot modify the items in a dictionary while iterating over it?

Answer: 
The two concepts are completely different. [Thread safety](http://en.wikipedia.org/wiki/Thread_safety) means that two threads cannot modify the same object at the same time, thereby leaving the system in an inconsistent state.

That said, you cannot modify a dictionary while iterating over it. See the [documentation.](http://docs.python.org/c-api/dict.html). 

> 
> The dictionary p should not be mutated during iteration. It is safe (since Python 2.1) to 
>  modify the values of the keys as you iterate over the dictionary, but only so long as the 
>  set of keys does not change.
> 
> 
>
No. Recent version of python will raise an exception if you try to iterate over a dictionary that has changed size between iterations.

```
>>> d={'one':1, 'two':2}
>>> for x in d:
...    d['three']=3
...    print x
...
two
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: dictionary changed size during iteration

```

Notice that you don't need to use threads to see this