python

What does this Python code do: shell=(sys.platform!="win32"))

I don't understand what this code is doing, I'm wanting to run a command line, in Mac OS X, the code I'm using is from somebody running a Windows command line. The command still executes, but I'd like to know what the sys.platform!="win32" is for, and if I should change it to something else for Mac OS X. It seems to be saying sys.pla...

Remove first 4 letters from a folder name using Bash scripting

As the title says I want to remove the first 4 letters from a folder name using a Bash script. If you have another way to do it in Linux I don't really mind e.g. Python. Also I need the script to be executed regularly (daily). ...

Merge two lists in python?

Just as it sounds: listone = [1,2,3] listtwo = [4,5,6] #outcome we expect: mergedlist == [1, 2, 3, 4, 5, 6] ...

Parsing people's first and last name in Python...

Thanks so much everyone who helped! So basically I need to parse a name and find the following info: First Name First Initial (if employee has initials for a first name like D.J., use both initials) Last Name (include if employee has a suffix such as Jr. or III.) So here's the interface I'm working with: Input: names = ["D.J. Ri...

how to run parallel job in python

i do data mining project in python, during experiment phase i have to run many experiment in same time, how i assign each process to run each experiment? which module i should use? ...

scrapy unknown scheduler middleware recursion problem

Dear everyone, I am using scrapy for scrapping I decided to write my own scheduler middleware to store some request to reduce the size of that within memory. Here is my code: def enqueue_request_into_scheduler(self, spider, request): print "ENQUEUE SCHEDULER with request %s" % str(request) scrapyengine.scheduler.enqueue_reques...

Cannot write a script to "svn export" in Python.

Hi, I would like to write a script that will tell another server to SVN export a SVN repository. This is my python script: import os # svn export to crawlers for s in ['work1.main','work2.main']: cmd = 'ssh %s "cd /home/zes/ ; svn --force export svn+ssh://174.113.224.177/home/svn/dragon-repos"' % s print cmd os.system(cmd)...

Python - List of Strings to Java

Hi, I'm getting a list of strings from python code and need to read it in Java. When trying to read it, i get the hashCode [Ljava.lang.Object;@7cf1bb78 I want to read the values in a list. In python my return is something like return SUCCESS(OK, params={'data':nameList()}) How would I read this in Java and print the contents no...

Non-blocking file access with Twisted

I'm trying to figure out if there is a defacto pattern for file access using twisted. Lots of examples I've looked at (twisted.python.log, twisted.persisted.dirdbm, twisted.web.static) actually don't seem to worry about blocking for file access. It seems like there should be some obvious interface, probably inheriting from abstract.Fil...

I just installed a Ubuntu Hardy server. In Python, I tried to import _mysql and MySQLdb

But, they were unable to be found!? How do I install both of them? ...

Is this python code thread-safe?

I am trying to make my chunk of code non-thread-safe, in order to toy with some exceptions that I want to add on later. This is my python code: from time import sleep from decimal import * from threading import Lock import random def inc_gen(c): """ Increment generator """ while True: #getting sleep period ...

Any python "compiler" that can statically link the python2x.dll dependency?

It's my understanding that py2exe can only dynamically link a python2x.dll file. Are there any Python "compilers" out there that can package it all into one standalone .exe file for easier portability? If so or if not, which is the best compiler z0mg! ...

Remove "add another" in Django admin screen

Whenever I'm editing object A with a foreign key to object B, a plus option "add another" is available next to the choices of object B. How do I remove that option? I configured a user without rights to add object B. The plus sign is still available, but when I click on it, it says "Permission denied". It's ugly. I'm using Django 1.0.2...

Unable to send function arguments from webapp.RequestHandler class

Hi, I am getting this errorpage after uploading my application to the google app engine and calling it in the browser. Traceback (most recent call last): File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 507, in __call__ handler.get(*groups) File "/base/data/home/apps/bulkloader160by2/1-5.3376956...

Howto bin series of float values into histogram in Python?

I have set of value in float (always less than 0). Which I want to bin into histogram, i,e. each bar in histogram contain range of value [0,0.150) The data I have looks like this: 0.000 0.005 0.124 0.000 0.004 0.000 0.111 0.112 Whith my code below I expect to get result that looks like [0, 0.005) 5 [0.005, 0.011) 0 ...etc.. I trie...

How can I measure the execution time of a for loop?

I want to measure the execution time of for loops on various platforms like php, c, python, Java, javascript... How can i measure it? I know these platforms so i am talking about these: for (i = 0; i < 1000000; i++) { } I don't want to measure anything within the loop. Little bit modification: @all Some of the friends of mine a...

Will python.subprocess(cppBinaryExe) compromise cppBinaryExe's performance?

hi, i am quite new to python.subprocess() if i folk a new process from python, will the execution speed of this new process be compromised? imagine that i have the #python import subprocess subprocess.call( MyBinary ) basically, is there any difference between ./MyBinary and ./python ruMyBinary.py ? ...

Is there any "remote console" for twisted server?

I am developing a twisted server. I need to control the memory usage. It is not a good idea to modify code, insert some memory logging command and restart the server. I think it is better to use a "remote console", so that I can type heapy command and see the response from the server directly. All I need is a remote console, I can build ...

Python dictionary simple way to add a new key value pair

Say you have, foo = 'bar' d = {'a-key':'a-value'} And you want d = {'a-key':'a-value','foo':'bar'} e = {'foo':foo} I know you can do, d['foo'] = foo #Either of the following for e e = {'foo':foo} e = dict(foo=foo) But, in all these way to add the variable foo to dict, I have had to use the word foo twice; once to indicate the k...

What is the equivalent of MATLAB's repmat in NumPy

I found repmat([1;1], [1 1 1]) in MATLAB code. I am trying to find a NumPy command to do the same thing, but I found that can't use with 3d [1 1 1] ? ...