Search Results

Search found 4755 results on 191 pages for 'scripting dictionary'.

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

  • Finding spelling of an element in an ignore case dictionary

    - by Andrew White
    Hi, Weird question, but I have a dictionary created with StringComparer.OrdinalIgnoreCase, looks something like this AaA, 10 aAB, 20 AAC, 12 I then use myDictionary["AAA"] to find the value associated with the key, but what I also need to know is what the actual spelling of the key is in myDictionary, e.g. in this case I want it to return AaA. Any way to do this without a loop? Thx.

    Read the article

  • Make dictionary from list with python

    - by prosseek
    I need to transform a list into dictionary as follows. The odd elements has the key, and even number elements has the value. x = (1,'a',2,'b',3,'c') - {1: 'a', 2: 'b', 3: 'c'} def set(self, val_): i = 0 for val in val_: if i == 0: i = 1 key = val else: i = 0 self.dict[key] = val My solution seems to long, is there a better way to get the same results?

    Read the article

  • Dictionary with single item

    - by alhazen
    In the case where Dictionary<object, object> myDictionary happens to contain a single item, what is the best way to retrieve the value object (if I don't care about the key) ? if (myDictionary.Count == 1) { // Doesn't work object obj = myDictionary.Values[0]; } Thanks

    Read the article

  • python / sets / dictionary / initialization

    - by Mario D
    Can someone explain help me understand how the this bit of code works? Particularly how the myHeap assignment works. I know the freq variable is assigned as a dictionary. But what about my myHeap? is it a Set? exe_Data = { 'e' : 0.124167, 't' : 0.0969225, 'a' : 0.0820011, 'i' : 0.0768052, } freq = exe_Data) myHeap = [[pct, [symbol, ""]] for symbol, pct in freq.items()]

    Read the article

  • rename keys in a dictionary

    - by user366660
    i want to rename the keys of a dictionary are which are ints, and i need them to be ints with leading zeros's so that they sort correctly. for example my keys are like: '1','101','11' and i need them to be: '001','101','011' this is what im doing now, but i know there is a better way tmpDict = {} for oldKey in aDict: tmpDict['%04d'%int(oldKey)] = aDict[oldKey] newDict = tmpDict

    Read the article

  • Dictionary Application

    - by Joy
    Hi all,I want to develop an iphone application that needs an english word dictionary. Can you people suggest me any link from where i can have that database containing a reasonable number of english words with their meanings and example sentence. Thanks in advance

    Read the article

  • number->string and related procedures in GIMP scheme scripting

    - by dim fish
    I am frustrated with string-to-number and number-to-string conversion in GIMP scripting. I am runnning GIMP 2.6.8 in Windows Vista. I understand that GIMP's internal Scheme implementation changes over the versions and I can't seem to nail down the documentation. From what I can gather GIMP's Scheme is a subset of TinyScheme and/or supports the R5RS standard procedures. In any case, I usually just look in the packaged script directory for examples when I want to try something new, because that should work for sure, right? For example, grid-system.scm comes with the latest GIMP release and has the expression, (string-append (number->string obj) " ") which is exactly what I want. However, if I use number-string in my own script, or even type it into GIMP's script console (which is how I usually test out new stuff I want to do) it tells me number-string is an unbound variable: > (number->string 3) Error: eval: unbound variable: number->string Other standard procedures from, say R5RS, work just fine: > (string-append "frust" "rated") "frustrated" So, 1) Is there some lurking documentation for current GIMP Scheme scripting other than something drastic like searching GIMP's source code? 2) Can I use the GIMP console to spit out a list of all defined procedures to find something I need? 3) Anyone else confirm that number-string is not defined for the current Windows build, even though it appears in the packaged scripts? My web searches haven't turned up any related problems, and a complete uninstall of all GIMP versions, back to latest puts me in the same scrape.

    Read the article

  • cross-platform scripting for windows, Linux, MacOS X

    - by karolrvn
    Hi. I'm looking for cross-platform scripting (language) for windows, Linux, MacOS X. I'm tired of .bat / bash . I would like to do things like for example ,,lock workstation'' at automatic login (I had this in X-Window but the solution was pretty ugly; now, I would like that on MS Windows and not that ugly :-) ). Generally: automate tasks. Or would I be better off with Windows Scripting Host? PowerShell also comes to mind, but that's seems to Windows-only for my taste. Can languages like Python, Ruby, (Java?) interact (elegantly? sensibly?) with WSH? Also things like DBUS, DCOM, etc come to mind as part of the picture. Currently I use a mixture of Java, .bat, bash, Ruby, Scala; some VBA for Excel. Which sometimes gets pretty ugly. I would like a cross-platform general solution with/using ,,native'' parts close to OS-specifics. Like e.g. Ruby driving some Windows-specific stuff (just a guess). What do You use? TIA

    Read the article

  • Embedded scripting engine in .Net app

    - by Nate
    I am looking to replace an old control being used for scripting an application. The control used to be called SAX Basic, but is now called WinWrap. It provides us with two primary functions. 1) It's a scripting engine (VB) 2) It has a GUI for developing and debugging scripts that get run in the hosting application. The first feature it provides is actually pretty easy to replace. There are so many great methods of running just about any kind of code at runtime that it's almost a non-issue. Just about any language targeting the .Net runtime will work for us. We've looked at running C#, PowerShell, VB.Net, IronPython, etc. I've also taken a brief look at Lua and F#, but honestly the language isn't the biggest barrier here. Now, for the hard part that seems to keep getting me stuck. We want a code editor, and debugger. Something simple, not unlike PowerShell's ISE would be fine. Just as long as a file could be created, saved, debugged and executed. I'm currently looking into Visual Studio 2010 Shell (Isolated) and I'm also looking at the feasibility of embedding PowerShell ISE in my application. Are there any other editor's I could embed/use in my application? Purchasing a product is not out of the question. It comes down to a combination of ease of use, how well it meets our needs, and how simple deployment and licensing is for developers. Thanks for the pointers

    Read the article

  • What are my choices for server side sandboxed scripting?

    - by alfa64
    I'm building a public website where users share data and scripts to run over some data. The scripts are run serverside in some sort of sandbox without other interaction this cycle: my Perl program reads from a database a User made script, adds the data to be processed into the script ( ie: a JSON document) then calls the interpreter, it returns the response( a JSON document or plain text), i save it to the database with my perl script. The script should be able to have some access to built in functions added to the scripting language by myself, but nothing more. So i've stumbled upon node.js as a javascript interpreter, and and hour or so ago with Google's V8(does v8 makes sense for this kind of thing?). CoffeeScript also came to my mind, since it looks nice and it's still Javascript. I think javascript is widespread enough and more "sandboxeable" since it doesn't have OS calls or anything remotely insecure ( i think ). by the way, i'm writing the system on Perl and Php for the front end. To improve the question: I'm choosing Javascript because i think is secure and simple enough to implement with node.js, but what other alternatives are for achieving this kind of task? Lua? Python? I just can't find information on how to run a sandboxed interpreter in a proper way.

    Read the article

  • Optimizing Python code with many attribute and dictionary lookups

    - by gotgenes
    I have written a program in Python which spends a large amount of time looking up attributes of objects and values from dictionary keys. I would like to know if there's any way I can optimize these lookup times, potentially with a C extension, to reduce the time of execution, or if I need to simply re-implement the program in a compiled language. The program implements some algorithms using a graph. It runs prohibitively slowly on our data sets, so I profiled the code with cProfile using a reduced data set that could actually complete. The vast majority of the time is being burned in one function, and specifically in two statements, generator expressions, within the function: The generator expression at line 202 is neighbors_in_selected_nodes = (neighbor for neighbor in node_neighbors if neighbor in selected_nodes) and the generator expression at line 204 is neighbor_z_scores = (interaction_graph.node[neighbor]['weight'] for neighbor in neighbors_in_selected_nodes) The source code for this function of context provided below. selected_nodes is a set of nodes in the interaction_graph, which is a NetworkX Graph instance. node_neighbors is an iterator from Graph.neighbors_iter(). Graph itself uses dictionaries for storing nodes and edges. Its Graph.node attribute is a dictionary which stores nodes and their attributes (e.g., 'weight') in dictionaries belonging to each node. Each of these lookups should be amortized constant time (i.e., O(1)), however, I am still paying a large penalty for the lookups. Is there some way which I can speed up these lookups (e.g., by writing parts of this as a C extension), or do I need to move the program to a compiled language? Below is the full source code for the function that provides the context; the vast majority of execution time is spent within this function. def calculate_node_z_prime( node, interaction_graph, selected_nodes ): """Calculates a z'-score for a given node. The z'-score is based on the z-scores (weights) of the neighbors of the given node, and proportional to the z-score (weight) of the given node. Specifically, we find the maximum z-score of all neighbors of the given node that are also members of the given set of selected nodes, multiply this z-score by the z-score of the given node, and return this value as the z'-score for the given node. If the given node has no neighbors in the interaction graph, the z'-score is defined as zero. Returns the z'-score as zero or a positive floating point value. :Parameters: - `node`: the node for which to compute the z-prime score - `interaction_graph`: graph containing the gene-gene or gene product-gene product interactions - `selected_nodes`: a `set` of nodes fitting some criterion of interest (e.g., annotated with a term of interest) """ node_neighbors = interaction_graph.neighbors_iter(node) neighbors_in_selected_nodes = (neighbor for neighbor in node_neighbors if neighbor in selected_nodes) neighbor_z_scores = (interaction_graph.node[neighbor]['weight'] for neighbor in neighbors_in_selected_nodes) try: max_z_score = max(neighbor_z_scores) # max() throws a ValueError if its argument has no elements; in this # case, we need to set the max_z_score to zero except ValueError, e: # Check to make certain max() raised this error if 'max()' in e.args[0]: max_z_score = 0 else: raise e z_prime = interaction_graph.node[node]['weight'] * max_z_score return z_prime Here are the top couple of calls according to cProfiler, sorted by time. ncalls tottime percall cumtime percall filename:lineno(function) 156067701 352.313 0.000 642.072 0.000 bpln_contextual.py:204(<genexpr>) 156067701 289.759 0.000 289.759 0.000 bpln_contextual.py:202(<genexpr>) 13963893 174.047 0.000 816.119 0.000 {max} 13963885 69.804 0.000 936.754 0.000 bpln_contextual.py:171(calculate_node_z_prime) 7116883 61.982 0.000 61.982 0.000 {method 'update' of 'set' objects}

    Read the article

  • Creating a constant Dictionary in C#

    - by David Schmitt
    What is the most efficient way to create a constant (never changes at runtime) mapping of strings to ints? I've tried using a const Dictionary, but that didn't work out. I could implement a immutable wrapper with appropriate semantics, but that still doesn't seem totally right. For those who have asked, I'm implementing IDataErrorInfo in a generated class and am looking for a way to make the columnName lookup into my array of descriptors. I wasn't aware (typo when testing! d'oh!) that switch accepts strings, so that's what I'm gonna use. Thanks!

    Read the article

  • Applescript file dialog with UI scripting

    - by Pepijn
    I am trying to open a file in a not so scriptable area of an application. I got halfway there by using UI scripting to select the proper menu item, but this opens a standard file dialog. How can I set the destination of the file dialog with Applescript?

    Read the article

  • Good way to get the key of the highest value of a Dictionary in C#

    - by Arda Xi
    I'm trying to get the key of the maximum value in the Dictionary<double, string> results. This is what I have so far: double max = results.Max(kvp => kvp.Value); return results.Where(kvp => kvp.Value == max).Select(kvp => kvp.Key).First(); However, since this seems a little inefficient, I was wondering whether there was a better way to do this.

    Read the article

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