dictionary

"Dictionary" with key as part of stored elements?

Seems like I forgot a typename ... Something inside my head keeps telling me that I have stumbled across a Dictionary that basicly uses a user-defined Comparer for lookups. But I somehow can't find that class in the depths of .Net anymore. As I have no real idea how to describe what I am looking for without describing a possible implme...

Determine whether a key is present in a Python dict

Possible Duplicate: 'has_key()' or 'in'? I have a Python dictionary like : mydict = {'name':'abc','city':'xyz','country','def'} I want to check if a key is in dictionary or not. I am eager to know that which is more preferable from the following two cases and why? 1> if mydict.has_key('name'): 2> if 'name' in mydict: ...

Check for a key pattern in a dictionary in python

dict1=({"EMP$$1":1,"EMP$$2":2,"EMP$$3":3}) How to check if EMP exists in the dictionary using python dict1.get("EMP##") ?? ...

Comparing two Dictionary of Dictionaries

Hi, I asked a similar question earlier in the week but I don't think my original description of the problem was very coherent, so I am trying again. I have the following Dictionaries: public Dictionary<string, List<DateTime>> 1stDict = new Dictionary<string, List<DateTime>>(); Dictionary<string, Dictionary<DateTime, double>> 2ndDict=...

dictionary data structure in R

In R, for example > foo <- list(a=1,b=2,c=3) if I type foo, get $a [1] 1 $b [1] 2 $c [1] 3 How can I look through foo to get a list of 'keys' only, in this case, (a, b, c)? Thanks all ...

What do I do when I need a self referential dictionary?

I'm new to Python, and am sort of surprised I cannot do this. dictionary = { 'a' : '123', 'b' : dictionary['a'] + '456' } I'm wondering what the Pythonic way to correctly do this in my script, because I feel like I'm not the only one that has tried to do this. EDIT: Enough people were wondering what I'm doing with this, so ...

How to include a definition language file in javascript?

I have a big javascript file common.js with all my functions and stuff...and i would like to write a separate file Js to store only the definitions for all the alert/courtesy messages etc spread along the file...i don't want to seek and change one by one... i have created something like this in php, where I have my file, en.php / fr....

Is there a Python equivalent to Ruby symbols?

Is there a Python equivalent to Ruby symbols? If so then what is it? If not then are we stuck with using strings as our keys in dictionaries only? ...

Why do you have to call .iteritems() when iterating over a dictionary in python?

Why do you have to call iteritems() to iterate over key, value pairs in a dictionary? ie dic = {'one':'1', 'two':'2'} for k, v in dic.iteritems(): print k, v Why isn't that the default behavior of iterating over a dictionary for k, v in dic: print k, v ...

Comparing two sets for new and missing keys

When comparing two key-value dictionary sets in C#: set A and set B, what is the best way to enumerate keys present in set A but missing from set B and vice-versa? For example: A = { 1, 2, 5 } B = { 2, 3, 5 } Comparing B with A, missing keys = { 1 } and new keys = { 3 }. Using Dictionary<...,...> objects, one can enumerating all val...

C# : Merging Dictionary and List

i'have a List of String like List<String> MyList=new List<String>{"A","B"}; and a Dictionary<String, Dictionary<String,String>> MyDict=new Dictioanry<String,Dictionary<String,String>>(); which contains Key Value Key Value "ONE" "A_1" "1" "A_2" "2" "X_1" "3" ...

How is the hash value of an object stored in a dictionary?

Hey guys! Friend of mine got asked the following question in an interview recently and im looking for a definitive answer for him. How is the hash value of an object stored in a dictionary? Cheers in advance! ...

Will I need a recursive function to iterate through a Dictionary<String, Object> of Dictionary<String, Object>s?

And there could be many levels, who knows how deep it could go! Also let's say for this specific question that the String for another Dictionary will be "Dictionary" and a value that I want to access/modify will be "Data". ...

Pass Dictionary as a web service GET parameter ?

can i Pass Dictionary as a web service GET parameter ? how will it look on the URL? do i pass it on the URL itself or in the header? ...

Python Array with String Indices

Is it possible to use strings as indices in an array in python? For example: myArray = [] myArray["john"] = "johns value" myArray["jeff"] = "jeffs value" print myArray["john"] ...

Python - Speed up generation of permutations of a list (and process of checking if permuations in Dict)

I need a faster way to generate all permutations of a list, then check if each one is in a dictionary. for x in range (max_combo_len, 0, -1): possible_combos = [] permutations = list(itertools.permutations(bag,x)) for item in permutations: possible_combos.append(" ".join(item))...

App.Config Redundancy Causing Runtime Problem

In my app.config in a C# 3.5 app, I have this section: <appSettings> <add key="deleteOldFiles" value="false"/> <! -- 25 other keys/values omitted --> <add key="deleteOldFiles" value="true"/> </appSettings> At initial app rollout, the system did not delete files because the first server engineer made the confi...

Add keys/values to Dictionary at declaration.

Very easy today, I think. In C#, its: Dictionary<String, String> dict = new Dictionary<string, string>() { { "", "" } }; But in vb, the following doesn't work. Public dict As Dictionary(Of String, String) = New Dictionary(Of String, String) (("","")) I'm pretty sure there's a way to add them at declaration, but I'm not sure how. ...

How to get a Dictionary<string, List<Object> with LINQ?

I have an object that looks like this: class Model { public string Category {get;set;} public string Description {get;set;} } Currently I am getting the whole list of those objects with Linq, and then manually setting up a dictionary, like this: List<Model> models = //get list from repository and then with linq order them by...

Python Sort Two Dimensional Dictionary By First Key

I have a 2D dictionary in python indexed by two IPs. I want to group the dictionary by the first key. For example, the before would look like this: myDict["182.12.17.50"]["175.12.13.14"] = 14 myDict["182.15.12.30"]["175.12.13.15"] = 10 myDict["182.12.17.50"]["185.23.15.69"] = 30 myDict["182.15.12.30"]["145.33.34.56"] = 230 so for ke...