dictionary

Can a dictionary be passed to django models on create?

Is is possible to do something similar to this with a list, dictionary or something else even? data_dict = { 'title' : 'awesome title', 'body' : 'great body of text', } Model.objects.create(data_dict) Even better if I can extend it Model.objects.create(data_dict, extra='hello', extra2='world) ...

Why can't a dictionary object be XmlSerialized in C#?

It seems that serialization is very straightforward. Assuming that both the key and value are serializable, what could be simpler than representing key-value pairs in XML?! To all the commenters: First of all, I appreciate your answers, But- I am less interested in workoraunds (There is indeed plenty of SerializableDictionary implementa...

Key compare using dictionary

Hi all, I have a file with the following structure: system.action.webMessage=An error has happened during web access. system.action.okMessage=Everything is ok. core.alert.inform=Error number 5512. I need a script to compare the keys in 2 files with this structure. I was working in a script to convert the file into a dictionary and use...

Is the password weak under dictionary attack

Thanks for looking. All sincerely helpful answers are voted up. I use a password strength meter to let the user know how strong the password they've chosen is. But this password checker obviously doesn't cover how weak under a dictionary attack the password is. How can I check for that, and is it worth it? Also my regular password ch...

C# exception: Key is not present in the dictionary

Hi there. I got a little problem. Sometimes, when I try to call the following code, the remove methods throw an exception with the message "the key is not present in the dictionary". private Dictionary<IPAddress, ARPHostEntry> dIPHostTable; private Dictionary<MACAddress, ARPHostEntry> dMACHostTable; public HostTable() { dIPHostTab...

dictionary web services api

Is there a free available public APIs that I can call to get the english dictionary word definitions? I would like to call it from python web app. ...

parsing string to a dict

I have a string output which is in form of a dict ex. {'key1':'value1','key2':'value2'} how can make easily save it as a dict and not as a string? ...

Accessing .NET dictionary in a multithreaded environment.

Dear ladies and sirs. I would like to emply the if-lock-if pattern for checking if an object is present in the dictionary in a multithreaded environment. So, the code I am considering looks like so: private IDictionary<string, SomeType> m_dic = new Dictionary<string, SomeType>(); private SomeType GetSomeObject(string key) { SomeType...

Dictionary/Client VS Application Variables

Hi i got a question about my server performance ... i got a classic asp cms hosting ~250 websites, for each website we build a Classic ASP dictionary using set dict = CreateObject("Scripting.Dictionary") dict.add "test1","Value Test1" dict.add "test2","Value Test2" dict.add "test3","Value Test3" that dictionary is then loaded on eve...

Dictionary Type mismatch in VBScript

The error I'm receiving is: Type mismatch: 'stylesheets' Stylesheets is defined as: sub stylesheets(collection) for each key in collection.Keys response.write(stylesheet(key, collection.Item(key))) next end sub ' returns a link tag for each object in the collection function stylesheet(asset, media_type) if (media_type...

Is there a better, pythonic way to do this?

This is my first python program - Requirement: Read a file consisting of {adId UserId} in each line. For each adId, print the number of unique userIds. Here is my code, put together from reading the python docs. Could you give me feedback on how I can write this in more python-ish way? CODE : import csv adDict = {} reader = csv.rea...

PHP: word definition script?

I am developing a web page in which I am accepting input words from user and when user will submit those words then I want to display definition of those words or wikipedia link of those words for more definition about that word. Something like below: Let's say user enetered 5 words: toast, egg, beans, coffee, tea Now I want to displ...

Simplest method to get the dictionary definitions of a list of words in a text file

File1: hello world I don't know the best method to extract a list of words from a text file, find their definitions and paste them into an output textfile. I've been thinking of using WordNet - but don't know how to automate the process. Does anyone have any ideas (perhaps google/APIs/linux applications) that one could use to find th...

Using a Python Dictionary as a Key (Non-nested)

Python doesn't allow dictionaries to be used as keys in other dictionaries. Is there a workaround for using non-nested dictionaries as keys? The general problem with more complicated non-hashable objects and my specific use case has been moved here. My original description of my use case was incorrect. ...

How the Dictionary is internally maintained ?

When i say Dictionary<int,string> is it equivalent to two different arrays such as: int[] keys =new int[] { 1, 2, 3 }; string[] values=new string[]{"val1","val2","val3"}; ...

What is a good way to test if a Key exists in Python Dictionary

I wanted to test if a key exists in a dictionary before updating the value for the key. I wrote the following code: if 'key1' in dict.keys(): print "blah" else: print "boo" I think this is not the best way to accomplish this task. Is there a better way to test for a key in the dictionary? ...

How to modify the Python 'default' dictionary so that it always returns a default value

I'm using all of them to print the names of assigned IANA values in a packet. So all of the dictionaries have the same default value "RESERVED". I don't want to use d.get(key,default) but access dictionaries by d[key] so that if the key is not in d, it returns the default (that is same for all dictionaries). I do not necessarily need ...

can i have an ordered dictionary by date

i have a dictionary where the key is a date and the value is an object. is there anyway i can ensure that when i loop through this collection its in chronological order always even after adding and deleting items. ...

Counting booleans in dictionary

I have a python dictionary object that contains a boolean for every key, e.g.: d = {'client1': True, 'client2': False} What is the easiest and most concise way to count the number of True values in the dictionary? ...

Using google as a dictionary lookup via bash, How can one grab the first definition?

#!/bin/bash # Command line look up using Google's define feature - command line dictionary echo "Type in your word:" read word /usr/bin/curl -s -A 'Mozilla/4.0' 'http://www.google.com/search?q=define%3A+'$word \ | html2text -ascii -nobs -style compact -width 500 | grep "*" Dumps a whole series of definitions from google.com an examp...