Search Results

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

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

  • FTP files in Windows Scripting Host?

    - by adib
    Hi What is the recommended way to transfer files via FTP and manage (rename, move, delete) files in an FTP server programmatically in a Windows Scripting Host script file (JavaScript/VBScript)? Preferably without requiring 3rd party ActiveX add-ons since these "extra" software will need to go through an approval process that will take a very long time, even for free (as in beer) and/or open source components. The script is going to be run in a Windows 2003 Server in data center environment. Thanks.

    Read the article

  • Pros/cons of embedded scripting environments?

    - by pomeroy
    There are several scripting environments available for .NET applications (e.g.this post). My question is, what are the pros/cons of using each of them? PowerShell IronPython Lua JavaScript I'm really looking for answers from folks that have tried to do this. Thanks.

    Read the article

  • Catching typos in scripting languages

    - by Geo
    If your scripting language of choice doesn't have something like Perl's strict mode, how are you catching typos? Are you unit testing everything? Every constructor, every method? Is this the only way to go about it?

    Read the article

  • how to copy a dictionary in python 3.1 and edit ONLY the copy

    - by MadSc13ntist
    can someone please explain this to me??? this doesn't make any sense to me.... I copy a dictionary into another and edit the second and both are changed???? ActivePython 3.1.0.1 (ActiveState Software Inc.) based on Python 3.1 (r31:73572, Jun 28 2009, 19:55:39) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. dict1 = {"key1":"value1", "key2":"value2"} dict2 = dict1 dict2 {'key2': 'value2', 'key1': 'value1'} dict2["key2"] = "WHY?!?!?!!?!?!?!" dict1 {'key2': 'WHY?!?!?!!?!?!?!', 'key1': 'value1'}

    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

  • how to change string values in dictionary to int values

    - by tom smith
    I have a dictionary such as: {'Sun': {'Satellites': 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Ceres,Pluto,Haumea,Makemake,Eris', 'Orbital Radius': '0', 'Object': 'Sun', 'RootObject': 'Sun', 'Radius': '20890260'}, 'Earth': {'Period': '365.256363004', 'Satellites': 'Moon', 'Orbital Radius': '77098290', 'Radius': '63710.41000.0', 'Object': 'Earth'}, 'Moon': {'Period': '27.321582', 'Orbital Radius': '18128500', 'Radius': '1737000.10', 'Object': 'Moon'}} I am wondering how to change just the number values to ints instead of strings. def read_next_object(file): obj = {} for line in file: if not line.strip(): continue line = line.strip() key, val = line.split(": ") if key in obj and key == "Object": yield obj obj = {} obj[key] = val yield obj planets = {} with open( "smallsolar.txt", 'r') as f: for obj in read_next_object(f): planets[obj["Object"]] = obj print(planets)

    Read the article

  • Converting the value from string to integer in a nested dictionary

    - by tom smith
    I want to change the numbers in my dictionary to int values for use later in my program. So far I have import time import math x = 400 y = 300 def read_next_object(file): obj = {} for line in file: if not line.strip(): continue line = line.strip() key, val = line.split(": ") if key in obj and key == "Object": yield obj obj = {} obj[key] = val yield obj planets = {} with open( "smallsolar.txt", 'r') as f: for obj in read_next_object(f): planets[obj["Object"]] = obj print(planets) scale=250/int(max([planets[x]["Orbital Radius"] for x in planets if "Orbital Radius" in planets[x]])) print(scale) and the output is {'Sun': {'Object': 'Sun', 'Satellites': 'Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Ceres,Pluto,Haumea,Makemake,Eris', 'Orbital Radius': '0', 'RootObject': 'Sun', 'Radius': '20890260'}, 'Moon': {'Object': 'Moon', 'Orbital Radius': '18128500', 'Period': '27.321582', 'Radius': '1737000.10'}, 'Earth': {'Object': 'Earth', 'Satellites': 'Moon', 'Orbital Radius': '77098290', 'Period': '365.256363004', 'Radius': '6371000.0'}} 3.2426140709476178e-06 I want to be able to convert the numbers in the dict to ints for further use. Any help in greatly appreciated.

    Read the article

  • python multiprocess update dictionary synchronously

    - by user1050325
    I am trying to update one common dictionary through multiple processes. Could you please help me find out what is the problem with this code? I get the following output: inside function {1: 1, 2: -1} comes here inside function {1: 0, 2: 2} comes here {1: 0, 2: -1} Thanks. from multiprocessing import Lock, Process, Manager l= Lock() def computeCopyNum(test,val): l.acquire() test[val]=val print "inside function" print test l.release() return a=dict({1: 0, 2: -1}) procs=list() for i in range(1,3): p = Process(target=computeCopyNum, args=(a,i)) procs.append(p) p.start() for p in procs: p.join() print "comes here" print a

    Read the article

  • python: calling constructor from dictionary?

    - by Jason S
    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 that by an operation on a dictionary provided to me: keys = {'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'} machineSpecificEnvironment = Environment( ... what do I put here? it needs to be a function of "keys" ... ) How can I do this?

    Read the article

  • Function for averages of tuples in a dictionary

    - by Billy Mann
    I have a string, dictionary in the form: ('the head', {'exploded': (3.5, 1.0), 'the': (5.0, 1.0), "puppy's": (9.0, 1.0), 'head': (6.0, 1.0)}) Each parentheses is a tuple which corresponds to (score, standard deviation). I'm taking the average of just the first integer in each tuple. I've tried this: def score(string, d): for word in d: (score, std) = d[word] d[word]=float(score),float(std) if word in string: word = string.lower() number = len(string) return sum([v[0] for v in d.values()]) / float(len(d)) if len(string) == 0: return 0 When I run: print score('the head', {'exploded': (3.5, 1.0), 'the': (5.0, 1.0), "puppy's": (9.0, 1.0), 'head': (6.0, 1.0)}) I should get 5.5 but instead I'm getting 5.875. Can't figure out what in my function is not allowing me to get the correct answer.

    Read the article

  • python - from matrix to dictionary in single line

    - by Sanich
    matrix is a list of lists. I've to return a dictionary of the form {i:(l1[i],l2[i],...,lm[i])} Where the key i is matched with a tuple the i'th elements from each list. Say matrix=[[1,2,3,4],[9,8,7,6],[4,8,2,6]] so the line: >>> dict([(i,tuple(matrix[k][i] for k in xrange(len(matrix)))) for i in xrange(len(matrix[0]))]) does the job pretty well and outputs: {0: (1, 9, 4), 1: (2, 8, 8), 2: (3, 7, 2), 3: (4, 6, 6)} but fails if the matrix is empty: matrix=[]. The output should be: {} How can i deal with this?

    Read the article

  • python dictionary with constant value-type

    - by s.kap
    hi there, I bumped into a case where I need a big (=huge) python dictionary, which turned to be quite memory-consuming. However, since all of the values are of a single type (long) - as well as the keys, I figured I can use python (or numpy, doesn't really matter) array for the values ; and wrap the needed interface (in: x ; out: d[x]) with an object which actually uses these arrays for the keys and values storage. I can use a index-conversion object (input -- index, of 1..n, where n is the different-values counter), and return array[index]. I can elaborate on some techniques of how to implement such an indexing-methods with reasonable memory requirement, it works and even pretty good. However, I wonder if there is such a data-structure-object already exists (in python, or wrapped to python from C/++), in any package (I checked collections, and some Google searches). Any comment will be welcome, thanks.

    Read the article

  • Creating dynamic dictionary

    - by Syom
    i must create something like dictionary in my site, but there is one problem, i don't imagine ho to solve. the client wants the following: in the CMS he must be able to write some specification to some words or even sentences, and after it, in the site, onmouseover() of that words, i must show it's specification in popup window. for example, in the cms he writes "hello word" - "specification of hello world", and then, in the site, if i have the text many many words here hello world and another words... onmouseover of "hello world" i must show "specification of hello world". the problem, that i don't know how to solve, is how to write the functions on the text content? could you give me an idea... Thanks

    Read the article

  • Do you know of a C dictionary that supports COW transactions?

    - by Tim Post
    I'm looking for a key - value dictionary library written in C that supports a theoretically unlimited number of cheap transactions. I'd like to have one dictionary in memory, with hundreds of threads starting transactions, possibly modifying the dictionary, ending (completing) the transaction or potentially aborting the transaction. Only 50% of the time will these threads actually modify the dictionary. Most dictionary transaction implementations that I've seen copy always, instead of copying on write, whenever a transaction is started. Given the expected size ( 1GB) of the dictionary, I'm hoping to find something that COWs only when something is actually changed during a transaction. I'm also hoping for something that is packaged by most major GNU/Linux distributions. Any suggestions or links are very much appreciated.

    Read the article

  • A scripting langauge for Windows?

    - by WhyKiki
    I work in Windows and often find the need to code some script that manipulates files or basic string manipulation. Currently, I'm doing this using PHP but having a LAMP stack for this seems overkill. I've tried things like autoHotkey but the syntax and functionality is horrific. So I'm looking for a scripting with: a) a sane syntax b) lots and lots of built-in libraries, functions, etc c) minimal setup. Preferably, I would like to code and run the script from my app launcher of choice, Executor

    Read the article

  • Adding items to dictionary if condition is true, else dont - python

    - by CodeTalk
    I'm trying to take an existing process: if self.path_object is not None: dictpath = {} for path in self.path_object: self.params = path.pathval.split("?")[0] self.params = path.pathval.split("&", 2) if path.pathval.contains(self.params): out = list(map(lambda v: v.split("=")[0] +"=" + str(self.fuzz_vectors), self.params)) else: pass dictpath[path] = out print dictpath I added the sub-if/else block in, but it is failing, stating: AttributeError: 'unicode' object has no attribute 'contains' on the if block . How can I fix it? I'm simply trying to do: if the path.pathval has either ? or & in it: add to dictionary else: pass #forget about it. Thanks!

    Read the article

  • Google I/O 2010 - Scripting Google Apps for business

    Google I/O 2010 - Scripting Google Apps for business Google I/O 2010 - Scripting Google Apps for business process automation Enterprise 201 Evin Levey Learn how to use Google Apps for business process automation, and custom work-flow. We'll introduce the powerful scripting service along with several easy-to-use interfaces including Spreadsheets, Calendar, Sites and the Document List. We'll also demonstrate interoperability with third party web services and showcase exciting new developments in Google Apps Script. For all I/O 2010 sessions, please go to code.google.com From: GoogleDevelopers Views: 8 0 ratings Time: 53:16 More in Science & Technology

    Read the article

  • Optimization of Function with Dictionary and Zip()

    - by eWizardII
    Hello, I have the following function: def filetxt(): word_freq = {} lvl1 = [] lvl2 = [] total_t = 0 users = 0 text = [] for l in range(0,500): # Open File if os.path.exists("C:/Twitter/json/user_" + str(l) + ".json") == True: with open("C:/Twitter/json/user_" + str(l) + ".json", "r") as f: text_f = json.load(f) users = users + 1 for i in range(len(text_f)): text.append(text_f[str(i)]['text']) total_t = total_t + 1 else: pass # Filter occ = 0 import string for i in range(len(text)): s = text[i] # Sample string a = re.findall(r'(RT)',s) b = re.findall(r'(@)',s) occ = len(a) + len(b) + occ s = s.encode('utf-8') out = s.translate(string.maketrans("",""), string.punctuation) # Create Wordlist/Dictionary word_list = text[i].lower().split(None) for word in word_list: word_freq[word] = word_freq.get(word, 0) + 1 keys = word_freq.keys() numbo = range(1,len(keys)+1) WList = ', '.join(keys) NList = str(numbo).strip('[]') WList = WList.split(", ") NList = NList.split(", ") W2N = dict(zip(WList, NList)) for k in range (0,len(word_list)): word_list[k] = W2N[word_list[k]] for i in range (0,len(word_list)-1): lvl1.append(word_list[i]) lvl2.append(word_list[i+1]) I have used the profiler to find that it seems the greatest CPU time is spent on the zip() function and the join and split parts of the code, I'm looking to see if there is any way I have overlooked that I could potentially clean up the code to make it more optimized, since the greatest lag seems to be in how I am working with the dictionaries and the zip() function. Any help would be appreciated thanks!

    Read the article

  • C# Dictionary Loop Enhancment

    - by Toto
    Hi, I have a dictionary with around 1 milions items. I am constantly looping throw the dictionnary : public void DoAllJobs() { foreach (KeyValuePair<uint, BusinessObject> p in _dictionnary) { if(p.Value.MustDoJob) p.Value.DoJob(); } } The execution is a bit long, around 600 ms, I would like to deacrese it. Here is the contraints : MustDoJob values mostly stay the same beetween two calls to DoAllJobs() 60-70% of the MustDoJob values == false From time to times MustDoJob change for 200 000 pairs. Some p.Value.DoJob() can not be computed at the same time (COM object call) Here, I do not need the key part of the _dictionnary objet but I really do need it somewhere else I wanted to do the following : Parallelizes but I am not sure is going to be effective due to 4. Sorts the dictionnary since 1. and 2. (and stop want I find the first MustDoJob == false) but I am wondering what 3. would result in I did not implement any of the previous ideas since it could be a lot of job and I would like to investigate others options before. So...any ideas ?

    Read the article

  • Upload image with Photoshop scripting

    - by cosmorocket
    Is that possible to upload an image from Photoshop (for example, an open image exported to jpeg) to some web place - REST service, FTP etc by using scripting features of Photoshop? For example - I have an image open in Photoshop and then execute some special script that sends an exported version of it to some place over the web. I saw something like this but it uses an automatically generated batch file that executes ftp command on Windows. I would like to use something more beautiful if it's possible. Or may be there are some info to know how to make a simple plugin for just this task. Thanks.

    Read the article

  • Scripting Bridge generates error creating a new playlist in iTunes on 10.5, but not 10.6

    - by Simone Manganelli
    I'm having a problem with the Scripting Bridge framework in 10.5. Specifically, I use this code to create a new user playlist in iTunes: NSDictionary *propertiesDict = [NSDictionary dictionaryWithObject:@"playlistName" forKey:@"name"]; playlistToReturn = (iTunesUserPlaylist*)[[[iTunesApp classForScriptingClass:@"user playlist"] alloc] initWithProperties:propertiesDict]; SBElementArray *sourcesArray = [iTunesApp sources]; iTunesSource *librarySource = [sourcesArray objectAtIndex:0]; SBElementArray *userPlaylistsArray = [librarySource userPlaylists]; [userPlaylistsArray addObject:playlistToReturn]; This code works fine in 10.6. The playlist is created correctly, and I can add songs to it later. However, on 10.5, an error is generated: Apple event:'core'\'crel'{ 'kocl':'cUsP', 'insh':'insl'{ 'kobj':'obj '{ 'want':'cUsP', 'from':'obj '{ 'want':'cSrc', 'from':'null'(), 'form':'ID ', 'seld':42 }, 'form':'indx', 'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{ 'pnam':'utxt'("playlistName") } }; Error Domain=SBError Code=-10014 UserInfo=0x152c8cb0 "Operation could not be completed. (SBError error -10014.)" Why?

    Read the article

  • Creating iPhoto albums using Cocoa Scripting Bridge

    - by robinjam
    I'm tearing my hair out trying to create a new album from a Cocoa Application. In applescript it's a nice simple procedure: tell application "iPhoto" new album name "Album" end tell But I can't work out how this is done in Cocoa via the Scripting Bridge. I've tried this: iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"]; iPhotoAlbum *newAlbum = [[[[iPhoto classForScriptingClass:@"album"] alloc] initWithProperties:[NSDictionary dictionaryWithObject:@"Album" forKey:@"name"]] autorelease]; [[iPhoto albums] addObject:newAlbum]; But that had no effect. Please help!

    Read the article

  • What Is The Best Scripting Language To Learn?

    - by Strider
    I have been learning C and C++ for sometime now. But, they do not allow me to do a lot of things like writing a script/program to get a bunch of files from the internet easily. So, I want to learn a scripting language which is fun and which is useful for everyday chores. Which one would you recommend, and why? Other information that might be useful: References to tutorials / helpful information on how to learn the language. References to implementations of the language. Niches where you have found it to be particularly useful.

    Read the article

  • New tab in Safari window from Cocoa and Scripting Bridge

    - by Thor Frølich
    I'm trying to create a new tab in a Safari window from Cocoa using Scripting Bridge. My code looks something like this: SafariApplication *safari = [SBApplication applicationWithBundleIdentifier:@"com.apple.Safari"]; if ([[safari windows] count] == 0) { NSLog(@"No window found. Creating a new one."); SafariDocument *newDoc = [[[safari classForScriptingClass:@"document"] alloc] init]; [[safari windows] addObject:newDoc]; [newDoc release]; } else { NSLog(@"Seems we already have a safari window"); SafariTab *newTab = [[[safari classForScriptingClass:@"tab"] alloc] init]; [[[safari windows] objectAtIndex:0] addObject:newTab]; [newTab release]; } The first part if the "if" works, creating a new window. Creating the tab does not. This gets me "-[SafariWindow addObject:]: unrecognized selector sent to instance...", so obviously that's not the way to do it. I can't figure out how windows, documents and tabs relate to each other in Safari. Any help is greatly appreciated. Thanks, Thor

    Read the article

  • How to write the content of a dictionary to a text file?

    - by codemonkie
    I have a dictionary object of type Dictionary and trying to use StreamWriter to output the entire content to a text file but failed to find the correct method from the Dictionary class. using (StreamWriter sw = new StreamWriter("myfile.txt")) { sw.WriteLine(dictionary.First()); } I can only retrieve the first element and it is bounded by a square bracket plus a comma separator in between as well: [Peter, Admin] and would be nice to have [Peter Admin] (without the comma)

    Read the article

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