Search Results

Search found 361 results on 15 pages for 'dictionaries'.

Page 9/15 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Very unusual and weird problem with gVim 7.2

    - by Fabian
    After installing gVim and running gvim from the run window, if I were to type :cd followed by a tab, I will get \AppData, \Application Data, etc. Which basically means I'm at my $HOME directory (C:\Users\Fabian). The weird thing is I do not have a \Application Data folder there. But if I were to run gvim.exe from its installation folder, and I type :cd followed by tab, I would get \autoload, \colors, etc. which means I'm at the installation folder. And if I were to pin gvim.exe on to taskbar, upon launch and typing :cd then tab, I will get \Dictionaries and upon hitting tab again I get a beep. I think for the last scenario, I'm at some Adobe folder. Anybody knows how to fix this weird issue? I'd like to pin it to taskbar and upon launch, start in the $HOME directory (C:\Users\Fabian).

    Read the article

  • Get directory contents in date modified order

    - by nevan
    Is there an method to get the contents of a folder in a particular order? I'd like an array of file attribute dictionaries (or just file names) ordered by date modified. Right now, I'm doing it this way: get an array with the file names get the attributes of each file store the file's path and modified date in a dictionary with the date as a key Next I have to output the dictionary in date order, but I wondered if there's an easier way? If not, is there a code snippet somewhere which will do this for me? Thanks.

    Read the article

  • how to delete contents from plist programmatically ?

    - by srikanth rongali
    I have a plist file. I want to delete the data from the plist. How can I do it programmatically ? My Plist have an array cells. cells is filled by dictionaries . Each dictionary is filled by string. I used the following way. NSString* plistPath1 = [[NSBundle mainBundle] pathForResource:@"details" ofType:@"plist"]; [cells removeObjectAtIndex:[clickedButtonPath row]]; NSMutableArray *array1 = [[NSMutableArray alloc] initWithCapacity:4]; array1 = cells; [array1 writeToFile:plistPath1 atomically: YES]; But the plist is not taking the changes. Thank you.

    Read the article

  • iPhone: Grouped Table Confusion

    - by senfo
    I'm trying to follow along with this UITableView tutorial and I'm afraid I'm getting confused. What I hope to accomplish is to create a grouped table, which resembles the look and feel of the following image (image source): For each "break" in the table, I assume that I need another section. I understand there is a global NSMutableArray, which acts as the data source to the UITableView. Inside this global array, there are dictionaries for sections and for data, but this is where I start getting confused. Should I create a unique table to store each section in addition to a new table for the rows that are part of that section? In other words, if I have five sections, will I end up with ten unique collections of data (one for each section and one to store the rows related to the section), which all eventually get stored in the global array?

    Read the article

  • Odd nested dictionary behavior in python

    - by adept
    Im new two python and am trying to grow a dictionary of dictionaries. I have done this in php and perl but python is behaving very differently. Im sure it makes sense to those more familiar with python. Here is my code: colnames = ['name','dob','id']; tablehashcopy = {}; tablehashcopy = dict.fromkeys(colnames,{}); tablehashcopy['name']['hi'] = 0; print(tablehashcopy); Output: {'dob': {'hi': 0}, 'name': {'hi': 0}, 'id': {'hi': 0}} The problem arises from the 2nd to last statement(i put the print in for convenience). I expected to find that one element has been added to the 'name' dictionary with the key 'hi' and the value 0. But this key,value pair has been added to EVERY sub-dictionary. Why? I have tested this on my ubuntu machine in both python 2.6 and python 3.1 the behaviour is the same.

    Read the article

  • How do I test ActionFilterAttributes that work with ModelState?

    - by Tomas Lycken
    As suggested by (among others) Kazi Manzur Rashid in this blog post, I am using ActionFilterAttributes to transfer model state from one request to another when redirecting. However, I find myself unable to write a unit test that test the behavior of these attributes. As an example, this what I want the test for the ImportModelStateAttribute to do: Setup the filterContext so that TempData[myKey] contains some fake "exported" ModelState (that is, a ModelStateDictionary I create myself, and add one error to) Make ModelState contain one model error. Call OnActionExecuting. Verify the two dictionaries are merged, and ModelState now contains both errors. I'm at a loss already on the second step.

    Read the article

  • Castle Windsor: Inject NameValueCollection vs. Dictionary

    - by Aren B
    I've already done many configs where dictionaries are passed into services in the <parameters> block. But what I find myself needing right now is to build a NameValueCollection (allowing multiple entries with the same key) or a Collection of KeyValuePair objects. The reason for this is im not using this dictionary to look up b when given a, im basically using it to pass in a Tuple (pair) of (a,b) to be used later in code. Im kind of new to castle windor and I was wondering how i would go about making a List of KeyValuePair's injected, or a NameValueCollection injected.

    Read the article

  • in-memory database in Python

    - by Claudiu
    I'm doing some queries in Python on a large database to get some stats out of the database. I want these stats to be in-memory so other programs can use them without going to a database. I was thinking of how to structure them, and after trying to set up some complicated nested dictionaries, I realized that a good representation would be an SQL table. I don't want to store the data back into the persistent database, though. Are there any in-memory implementations of an SQL database that supports querying the data with SQL syntax?

    Read the article

  • Document Similarity: Comparing two documents efficiently

    - by seanieb
    I have a loop that calculates the similarity between two documents. It collects all the tokens in a document and their scores, and places them in dictionary. It then compares the dictionaries This is what I have so far, it works, but is super slow: # Doc A cursor1.execute("SELECT token, tfidf_norm FROM index WHERE doc_id = %s", (docid[i][0])) doca = cursor1.fetchall() #convert tuple to a dictionary doca_dic = dict((row[0], row[1]) for row in doca) #Doc B cursor2.execute("SELECT token, tfidf_norm FROM index WHERE doc_id = %s", (docid[j][0])) docb = cursor2.fetchall() #convert tuple to a dictionary docb_dic = dict((row[0], row[1]) for row in docb) # loop through each token in doca and see if one matches in docb for x in doca_dic: if docb_dic.has_key(x): #calculate the similarity by summing the products of the tf-idf_norm similarity += doca_dic[x] * docb_dic[x] print "similarity" print similarity I'm pretty new to Python, hence this mess. I need to speed it up, any help would be appreciated. Thanks.

    Read the article

  • Multiple levels of 'collection.defaultdict' in Python

    - by Morlock
    Thanks to some great folks on SO, I discovered the possibilities offered by collections.defaultdict, notably in readability and speed. I have put them to use with success. Now I would like to implement three levels of dictionaries, the two top ones being defaultdict and the lowest one being int. I don't find the appropriate way to do this. Here is my attempt: from collections import defaultdict d = defaultdict(defaultdict) a = [("key1", {"a1":22, "a2":33}), ("key2", {"a1":32, "a2":55}), ("key3", {"a1":43, "a2":44})] for i in a: d[i[0]] = i[1] Now this works, but the following, which is the desired behavior, doesn't: d["key4"]["a1"] + 1 I suspect that I should have declared somewhere that the second level defaultdict is of type int, but I didn't find where or how to do so. The reason I am using defaultdict in the first place is to avoid having to initialize the dictionary for each new key. Any more elegant suggestion? Thanks pythoneers!

    Read the article

  • plist vs static array

    - by morticae
    Generally, I use static arrays and dictionaries for containing lookup tables in my classes. However, with the number of classes creeping quickly into the hundreds, I'm hesitant to continue using this pattern. Even if these static collections are initialized lazily, I've essentially got a bounded memory leak going on as someone uses my app. Most of these are arrays of strings so I can convert strings into NSInteger constants that can be used with switch statements, etc. I could just recreate the array/dictionary on every call, but many of these functions are used heavily and/or in tight loops. So I'm trying to come up with a pattern that is both performant and not persistent. If I store the information in a plist, does the iphoneOS do anything intelligent about caching those when loaded? Do you have another method that might be related?

    Read the article

  • python decorator to modify variable in current scope

    - by AlexH
    Goal: Make a decorator which can modify the scope that it is used in. If it worked: class Blah(): # or perhaps class Blah(ParentClassWhichMakesThisPossible) def one(self): pass @decorated def two(self): pass Blah.decorated ["two"] Why? I essentially want to write classes which can maintain specific dictionaries of methods, so that I can retrieve lists of available methods of different types on a per class basis. errr..... I want to do this: class RuleClass(ParentClass): @rule def blah(self): pass @rule def kapow(self): pass def shazam(self): class OtherRuleClass(ParentClass): @rule def foo(self): pass def bar(self): pass RuleClass.rules.keys() ["blah", "kapow"] OtherRuleClass.rules.keys() ["foo"]

    Read the article

  • Need a .NET Dictionary<string,object> with just a little more functionality.

    - by Ronnie Overby
    I need a dictionary but I also need to store a boolean value about the object in the dictionary. What's the best way for this. Something like Dictonary<string,object,bool> would be ideal, but doesn't exist. My first idea was: public class SomeObject { public object Value { get; set; } public bool Flag { get; set; } } // and then use: Dictionary<string,SomeObject> myDictionary; My 2nd idea was to implement IDictionary and contain two dictionaries within that were manipulated by the implemented methods and property accessors. My 3rd idea was to see what the folks at StackOverflow would do.

    Read the article

  • Convert a sequence of sequences to a dictionary and vice-versa

    - by louis
    One way to manually persist a dictionary to a database is to flatten it into a sequence of sequences and pass the sequence as an argument to cursor.executemany(). The opposite is also useful, i.e. reading rows from a database and turning them into dictionaries for later use. What's the best way to go from myseq to mydict and from mydict to myseq? >>> myseq = ((0,1,2,3), (4,5,6,7), (8,9,10,11)) >>> mydict = {0: (1, 2, 3), 8: (9, 10, 11), 4: (5, 6, 7)}

    Read the article

  • Is NSDictionary key order guaranteed the same as initialized if it never changes?

    - by Thaurin
    I've run into the same problem as found in this question. However, I have a follow-up question. I seem to be in the same situation as the original asker: I have a plist with a hierarchy of dictionaries that define a configuration screen. These are not mutable and will stay the same throughout the application. Since the original discussion seems to focus on problems arising from mutating the dictionary, I must ask for comfirmation: is the order of a dictionary guaranteed the same as they are in the plist, i.e. as it is read (with initWithContentsOfFile)? Can I use allKeys on it in this case to get a correct-order array of keys if the dictionary never changes?

    Read the article

  • Is there a SortedList<T> class in .net ? (not SortedList<Key,Value> which is actually a kind of Sort

    - by Brann
    I need to sort some objects according to their contents (in fact according to one of their properties, which is NOT the key and may be duplicated between different objects) .net provides two classes (SortedDictionnary and SortedList), and both are some kind of Dictionaries. The only difference (AFAIK) is that SortedDictionnary uses a binary tree to maintain its state whereas SortedList does not and is accessible via an index. I could achieve what I want using a List, and then using its Sort() method with a custom implementation of IComparer, but it wouldn't be time-efficient as I would sort the whole List each time I insert a new object, whereas a good SortedList would just insert the item at the right position. What I need is a SortedList class with a RefreshPosition(int index) to move only the changed (or inserted) object rather than resorting the whole list each time an object inside changes. Am I missing something obvious ?

    Read the article

  • Differences between WPF Custom Control Library and plain Class Library?

    - by David Veeneman
    I posted a question a few months ago about sharing resource dictionaries across assemblies. It turns out you can do that using the Component Resource Key markup extension. At the time, I could only get it working with a WPF Custom Control project, not with a plain Class Library project. Now I need to use an existing plain Class Library project to host a shared resource dictionary. That means I need to retrofit the Class Library project to support the Component Resource Key markup extension. I have added a Themes folder and a Generic.xaml resource dictionary document to the Class Library project, as well as references to PresentationCore, PresentationFramework, and WindowsBase. Unfortunately, that doesn't seem to do the trick. So, here is my question: Other than the above, what does a WPF Custom Control Library project have that a plain Class Library project doesn't? Or, to put it another way, what else could I add to my class library project to get this feature working? Thanks.

    Read the article

  • Redirect print in Python: val = print(arg) to output mixed iterable to file

    - by emcee
    So lets say I have an incredibly nested iterable of lists/dictionaries. I would like to print them to a file as easily as possible. Why can't I just redirect print to a file? val = print(arg) gets a SyntaxError. Is there a way to access stdinput? And why does print take forever with massive strings? Bad programming on my side for outputting massive strings, but quick debugging--and isn't that leveraging the strength of an interactive prompt? There's probably also an easier way than my gripe. Has the hive-mind an answer?

    Read the article

  • Can I add custom methods/attributes to built-in Python types?

    - by sfjedi
    For example—say I want to add a helloWorld() method to Python's dict type. Can I do this? JavaScript has a prototype object that behaves this way. Maybe it's bad design and I should subclass the dict object, but then it only works on the subclasses and I want it to work on any and all future dictionaries. Here's how it would go down in JavaScript: String.prototype.hello = function() { alert("Hello, " + this + "!"); } "Jed".hello() //alerts "Hello, Jed!" Here's a useful link with more examples— http://www.javascriptkit.com/javatutors/proto3.shtml

    Read the article

  • Creating many new instances vs reusing them?

    - by Hugo Riley
    I have multiple business entities in VB.NET Windows Forms application. Right now they are instanced on application startup and used when needed. They hold descriptions of business entities and methods for storing and retrieving data. To cut the long story short, they are somewhat heavy objects to construct (they have some internal dictionaries and references to other objects) created and held in one big global variable called "BLogic". Should I refactor this so that each object is created when needed and released when out of scope? Then every event on UI will probably create a few of this objects. Should I strive to minimize creation of new objects or to minimize number of static and global objects? Generally I am trying to minimize the scope of every variable but should I treat this business logic objects specially?

    Read the article

  • How to have a dynamic theme color in WPF

    - by Ingó Vals
    In WPF I have a few resource dictionaries and in them styles for my panels and controls in my app. I'm reusing the same colors again and again. I actually have 5 colors and they give my app a good color-scheme. However if I wan't to change the theme I have to go into the RD's and change each and every color there. I would like to somewhere have the colors set but don't know how or where. I tried to put a color tag in one RD but as soon as I referenced it in the same RD Visual Studio crashed. Also the best solution would be that I could have the color as a dynamic setting in the app itself so users could even change it themselves.

    Read the article

  • Suggestion for creating custom sound recognition software to toggle audio

    - by Parrot owner
    I need to develop a program that toggles a particular audio track on or off when it recognizes a parrot scream or screech. The software would need to recognize a particular range of sounds and allow some variations in the range (as a parrot likely won't replicate its sreeches EXACTLY each time). Example: Bird screeches, no audio. Bird stops screeching for five seconds, audio track praising the bird plays. Regular chattering needs to be ignored completely, as it is not to be discouraged. I've heard of java libraries that have speech recognition with dictionaries built in, but the software would need to be taught the particular sounds that my particular parrot makes - not words or any random bird sound. In addition as I mentioned above, it would need to allow for slight variation in the sound, as the screech will likely never be 100% identical to the recorded version. What would be the best way to go about this/what language should I look into?

    Read the article

  • python decorator to add function to list in current scope

    - by AlexH
    Goal: Make a decorator which can modify the scope that it is used in. If it worked: class Blah(): # or perhaps class Blah(ParentClassWhichMakesThisPossible) def one(self): pass @decorated def two(self): pass Blah.decorated ["two"] Why? I essentially want to write classes which can maintain specific dictionaries of methods, so that I can retrieve lists of available methods of different types on a per class basis. errr..... I want to do this: class RuleClass(ParentClass): @rule def blah(self): pass @rule def kapow(self): pass def shazam(self): class OtherRuleClass(ParentClass): @rule def foo(self): pass def bar(self): pass RuleClass.rules.keys() ["blah", "kapow"] OtherRuleClass.rules.keys() ["foo"]

    Read the article

  • how to search values in a dictionary that is assigned to a key for a PFObject without downloading all PFObjects of that class (iOS/Parse)

    - by mkc842
    Suppose I have a set of PFObjects (essentially dictionaries) of class "myObject". Objects of this class contain for key "myDictionary" a dictionary. "myDictionary", in turn, has a key "myKey" that I want to access and search for matches against "mySearchTerm". I don't want to download all myObject objects and then iterate through them to check myKey in each, because that would be very inefficient. I want to use a findObjects message to return just the matches. Is such a query possible? In other words, how can I search the values in a dictionary that is assigned to a key for a PFObject without downloading all PFObjects of that class? Here's what it might look like if there were a simple method for it, but I made up the containsKey part to clarify what I am contemplating: PFQuery *objectQuery = [PFQuery queryWithClassName:@"myObject"]; [objectQuery whereKey:@"myDictionary" ~containsKey~:@"myKey" equalTo:"mySearchTerm"];

    Read the article

  • List of drugs to parse in application

    - by Skoder
    Hey, Not sure if that has been asked before, but semantics causes difficulty in searching. Are there any sites which have a list of items for developers to use in applications? For example, you can download Dictionaries in specific formats (e.g. XML) for use in word games. In particular, I was hoping that there might be a list of common medical drugs so that I can use display a list in an application I'm working on as researching and typing 150+ drug names would be quite inefficient. Thanks

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15  | Next Page >