dictionary

Possible to do ordered dictionary in python 2.5 (due to GAE)?

I'm new to Python, and using Google App Engine, which is currently running only Python 2.5. Are there any built-in ways of doing an ordered dictionary, or do I have to implement something custom? ...

Ienumerable Extension method for dictionary array calls

Hi All Im trying to get an enumberable collection from a dictionary held array. Or should I say, I'm trying to write an extension method for my dictionary objects which store arrays to return an IEnumerable item when the result is null. Im using dictionarys to store array datasets (there are speed reasons for this), which I extract at ...

Marshalling a C# Dictionary over COM interop to C++

Is there a good way of marshalling a Dictionary<string, string> over COM interop? Ideas so far include tokenising each KeyPair to an array of strings which can be marshalled as a SafeArray, or having two string arrays containing keys and values. Neither seems particularly satisfactory. Any ideas? ...

Pythonic way to write create dictionary from dict comprehension, + something else

I want to do something like this: parsetable = { # ... declarations: { token: 3 for token in [_id, _if, _while, _lbrace, _println] }.update({_variable: 2}), #... } However this doesn't work because update doesn't return a...

How to remove an IList<Class> value using dictionary key.

For example I have a class named Temp then I assigned values to it using an IList<Temp>. After populating the IList<Temp> I created a dictionary and assign an int key to each object. My question is that how do I remove from IList and dictionary the temp_value with the name b and a with a key value of "2"? class Temp { public string ...

Comparing 2 Dictionary<string, string> Instances

I want to compare the contents of two Dictionary<string, string> instances regardless of the order of the items they contain. SequenceEquals also compares the order, so I first order the dictionaries by key and then call SequenceEquals. Is there a method that I can use instead of SequenceEquals that will only compare the contents? I...

Python appending dictionary, TypeError: unhashable type ??

abc = {} abc[int: anotherint] Then the error came up. TypeError: unhashable type? Why I received this? I've tried str() ...

Download an English dictionary

Hello, I wondered if anyone could point me in the direction of a English dictionary download (free). I do NOT want: Spelling check dictionaries Links to websites that don't provide me with an actual dictionary Dictionaries in some weird format I want something like a notepad or SQL script that has the following simple format: Hat...

accessing python dictionary

I am writing code that will search twitter for key words and store them in a python dictionary: base_url = 'http://search.twitter.com/search.json?rpp=100&amp;q=4sq.com/' query = '7bOHRP' url_string = base_url + query logging.info("url string = " + url_string) json_text = fetch(url_string) ...

Find and replace in CSV files with Python

Related to a previous question, I'm trying to do replacements over a number of large CSV files. The column order (and contents) change between files, but for each file there are about 10 columns that I want and can identify by the column header names. I also have 1-2 dictionaries for each column I want. So for the columns I want, I want...

How to create a dictionary in C?

I'm programming a microcontroller in C and as part of it want to display certain letters on a 7 segment display. Each letter has a corresponding number that makes the 7 segment display show the letter. There's no real pattern to it cause the number is just made by adding up the bits on the 7 segment display that are needed to show the le...

Get a sub-set of a Python dictionary

I have a dictionary: {'key1':1, 'key2':2, 'key3':3} I need to pass a sub-set of that dictionary to third-party code. It only wants a dictionary containing keys ['key1', 'key2', 'key99'] and if it gets another key (eg 'key3'), it explodes in a nasty mess. The code in question is out of my control so I'm left in a position where I have ...

Beginner in a desperate need of python help.

Beginner programmer here! I need to write a simple phone book application. My program should be able to add names and phone numbers to a database. I should use a dictionary to store the information. If the user's input is empty, my program should stop, otherwise it should keep on asking inputs. Honestly I am lost here. I need help. ...

Nested Dictionaries in Python, with implicit creation of non-existing intermediate containers?

I want to create a polymorphic structure that can be created on the fly with minimum typing effort and be very readable. For example: a.b = 1 a.c.d = 2 a.c.e = 3 a.f.g.a.b.c.d = cucu a.aaa = bau I do not want to create an intermediate container such as: a.c = subobject() a.c.d = 2 a.c.e = 3 My question is similar to this one: http...

Python: Convert this list into dictionary

Hi, I've got a problem , and do not know how to code in python. I've got a list[10, 10, 10, 20, 20, 20, 30] I want it be in a dictionary like this {"10": 1, "20": 3, "30" : 1} How could I achieve this? ...

Read python dictionary using c++

Hi I have a python dictionary stored in a file which I need to access from a c++ program. What is the best way of doing this? Thanks ...

How to serialize the Key and only one object value of a generic Dictionary<TKey, TValue> ?

Hi all, I am looking forward to serialize a Dictionary in order to save some of it's information, more precisely it's Key and one of it's Value, into Silverlight Isolated storage. I have read many question talking about the same subject on these boards, but none were explaining what I was trying to do, or at least not in a way I could u...

Convert dictionary to list collection in C#

I have problem when trying to convert dictionary to list. Example if I have dictionary with template string as key and string as value. Then i wish to convert dictionary key to list collection as string. Dictionary<string, string> dicNumber = new Dictionary<string, string>(); List<string> listNumber = new List<string>(); dicNumber.Add...

Python variables as keys to dict

Hello, Is there an easier way to do this in Python (2.7)?: Note: This isn't anything fancy, like putting all local variables into a dictionary. Just the ones I specify in a list. apple = 1 banana = 'f' carrot = 3 fruitdict = {} # I want to set the key equal to variable name, and value equal to variable value # is there a more Pythonic...

Parse and pivot student assignment data in c#

I've got a list of student/assignment pairs coming in to my application via flat file into a List object and I'd like to validate those assignment names against a list of assignments I have to see which student has done what assignment (if any). So - I have a list of students, a list of student/assignment pairs, and a list of assignment...