dictionary

Loading a DB table into nested dictionaries in Python

Hi, I have a table in MySql DB which I want to load it to a dictionary in python. the table columns is as follows: id,url,tag,tagCount tagCount is the number of times that a tag has been repeated for a certain url. So in that case I need a nested dictionary, in other words a dictionary of dictionary, to load this table. Because each u...

Is it possible to access the inner property of a JQuery plugin?

I'm trying to alter the extraParams in this plugin based on a user action. var t = new $.TextboxList('#entSearch', {unique: true, plugins: { autocomplete: { minLength: 3, queryRemote: true, placeholder: false, remote: { url: "{{=URL(r=requ...

python: calling constructor from dictionary?

I'm not quite sure of the terminology here so please bear with me.... Let's say I have a constructor call like this: machineSpecificEnvironment = Environment( TI_C28_ROOT = 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000', JSDB = 'c:/bin/jsdb/jsdb.exe', PYTHON_PATH = 'c:/appl/python/2.6.4', ) except I would like to replace ...

Python: converting string to flags

If I have a string that is the output of matching the regexp [MSP]*, what's the cleanest way to convert it to a dict containing keys M, S, and P where the value of each key is true if the key appears in the string? e.g. 'MSP' => {'M': True, 'S': True, 'P': True} 'PMMM' => {'M': True, 'S': False, 'P': True} '' => {'M': False, 'S...

How can I overload the [] operators?

I'm creating a class which populates a dictionary as a private member. I want to expose the values of the dictionary without exposing the dictionary itself (in a read-only fashion.) I can easily make a property to expose _dictionary.Keys, but how can I overload [] so that MyClass[key] returns _dictionary[key]? I think I may need to impl...

Wherewith replace Dictionary.Where(p => p.Key is T)

I have a System.Collections.Generic.Dictionary<System.Web.UI.Control, object> where all keys can be either type of System.Web.UI.WebControls.HyperLink or type of System.Web.UI.WebControls.Label. I want to change Text property of each control. Because HyperLink doesn't implement (why??) ITextControl, I need to cast Label or HyperLink exp...

C#: IEnumerable, GetEnumerator, a simple, simple example please!

Hi there, Trying to create an uebersimple class that implements get enumerator, but failing madly due to lack of simple / non-functioning examples out there. All I want to do is create a wrapper around a data structure (in this case a list, but I might need a dictionary later) and add some functions. public class Album { public rea...

iPad built in dictionary

Is the built-in dictionary in iBooks etc available to developers? If so how would I go about using it? ...

Is there an java API to retreive the sound for word pronunciation?

Most of the dictionary sites provide a mechanism to hear the sound of the word, are there API(s) which allow you to retreive this sound file. eSpindle seems to do this, but I don't think this is free. ...

python: identifying duplicate values across disparate dictionary keys

here is an example of the dict ActivePython 3.1.2.3 (ActiveState Software Inc.) based on Python 3.1.2 (r312:79147, Mar 22 2010, 12:20:29) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> dict = {} >>> dict[("127.0.0.1", "127.0.0.2")] = ["value", "value2", "value3"] >>> dict...

How do I count the highest key in a python dictionary? (very pythonic way?) EDIT: make a list

d = {'apple':9,'oranges':3,'grapes':22} How do I return the largest key/value? Edit: How do I make a list that has this sorted by largest to lowest value? ...

Problem in converting ToDictionary<Datetime,double>() using LINQ(C#3.0)

I have written the below return (from p in returnObject.Portfolios.ToList() from childData in p.ChildData.ToList() from retuns in p.Returns.ToList() select new Dictionary<DateTime, double> () { p.EndDate, retuns.Value } ).ToDictionary<DateTime,double>(); Getting error No overload for method 'Add' ...

how to create english language dictionary application with python (django)?

Hi All, I would like to create an online dictionary application by using python (or with django). It will be similar to http://dictionary.reference.com/. PS: the dictionary is not stored in a database. it's stored in a text file or gunzip file. Free english dictionary files can be downloaded from this URL: dicts.info/dictionaries.php...

When to use dictionaries?

I`m not really sure when I should use a dictionary in my applications. Everytime I code a switch case that returns a single value, for example, should I strive for a dic? Thanks ...

c# Best class to hold a list of values to look up after

I have a list of values that i need to check against a constant list to know wheter they are present or not (one by one). Im using a dictionary buy it doesnt seem logical to have the value two times (key, value)...isnt there any class specialized for this case (and faster if possible)? Also it would me more reasonable if it could be de...

Python, store a dict in a database

What's the best way to store and retrieve a python dict in a database? ...

Composite Key Dictionary

I have some objects in List, let's say List<MyClass> and MyClass has several properties. I would like to create an index of the list based on 3 properties of of MyClass. In this case 2 of the properties are int's, and one property is a datetime. Basically I would like to be able to do something like: Dictionary< CompositeKey , MyClas...

Sort a list of dicts by dict values

I have a list of dictionaries: [{'title':'New York Times', 'title_url':'New_York_Times','id':4}, {'title':'USA Today','title_url':'USA_Today','id':6}, {'title':'Apple News','title_url':'Apple_News','id':2}] I'd like to sort it by the title, so elements with A go before Z: [{'title':'Apple News','title_url':'Apple_News','id':2}, {'...

In python, a good way to remove a list from a list of dicts

I have a list of dicts: list = [{'title': u'Politics', 'id': 1L, 'title_url': u'Politics'}, {'id': 3L, 'title_url': u'Test', 'title': u'Test'}] I'd like to remove the list item with title = 'Test' What is the best way to do this given that the order of the key/value pairs change? Thanks. ...

What must be done to use the value of a reference type as a dictionary key?

Suppose I have a class T that I want to use as a key in a Dictionary<T,U> collection. What must I implement in T so that these keys are based on values of T rather than T references? I'm hoping it's just GetHashCode(). ...