Top "Dictionary" questions

A dictionary maps keys to values allowing efficient retrieval of values by keys.

How do I create a dictionary with keys from a list and values defaulting to (say) zero?

I have a = [1,2,3,4] and I want d = {1:0, 2:0, 3:0, 4:0} d = dict(zip(q,[0 for x in range(0,len(q))])) works but is …

python dictionary
Java time-based map/cache with expiring keys

Do any of you know of a Java Map or similar standard data store that automatically purges entries after a …

java caching dictionary
Convert Django Model object to dict with all of the fields intact

How does one convert a Django Model object to a dict with all of its fields? All ideally includes foreign …

python django dictionary django-models
.NET HashTable Vs Dictionary - Can the Dictionary be as fast?

I am trying to figure out when and why to use a Dictionary or a HashTable. I have done a …

c# .net collections dictionary hashtable
Convert a Map<String, String> to a POJO

I've been looking at Jackson, but is seems I would have to convert the Map to JSON, and then the …

json dictionary jackson pojo
Python - Create a list with initial capacity

Code like this often happens: l = [] while foo: #baz l.append(bar) #qux This is really slow if you're about …

python list dictionary initialization
How do I format a string using a dictionary in python-3.x?

I am a big fan of using dictionaries to format strings. It helps me read the string format I am …

python string dictionary python-3.x
What is more efficient: Dictionary TryGetValue or ContainsKey+Item?

From MSDN's entry on Dictionary.TryGetValue Method: This method combines the functionality of the ContainsKey method and the Item property. …

c# performance dictionary
How to delete items from a dictionary while iterating over it?

Is it legitimate to delete items from a dictionary in Python while iterating over it? For example: for k, v …

scripting dictionary python
String to Dictionary in Python

So I've spent way to much time on this, and it seems to me like it should be a simple …

python string json facebook dictionary