python

Fitting a gamma distribution with (python) Scipy

Hi folks, Can anyone help me out in fitting a gamma distribution in python? Well, I've got some data : X and Y coordinates, and I want to find the gamma parameters that fit this distribution... In the Scipy doc, it turns out that a fit method actually exists but I don't know how to use it :s.. first, in wich format the argument "data" ...

how can i increase the speed of socket

how can i increase speed of socket in python ? my code : import urllib proxies = {'http': 'http://75.21.47.2:8080/'} opener = urllib.FancyURLopener(proxies) r = opener.open("http://www.python.org/") print r.read() ...

Any PHP or Python alternatives for Liferay and Alfresco ?

Hello, My company wants to use Liferay for developing a portal and integrate Alfresco with it for document management. But both Liferay and Alfresco are Java based and i would like to know if there are any alternatives to Liferay and Alfresco in PHP or Python. Thank You ...

Build a decision tree for classification of large amount data,using python?

Hi,i am working for speech synthesis.In this i have a large number of pronunciation for each phone i.e alphabet and need to classify them according to few feature such as segment size(int) and alphabet itself(string) into a smaller set suitable for that particular context. For this purpose,i have decided to use decision tree for classifi...

Are there any guidelines available for beginning Python with Python 2.6 to write applications easily migratable to Python 3 in future?

Possible Duplicate: Tips on upgrading to python 3.0? I am beginning Python and Python 3 is hardly a choice today. But I want the new code I write to have no problems running or being converted to Python 3. Are there any issues known that I should keep in mind for this? ...

Overriding Django Admin's main page? - Django

Hi folks, I'm trying to add features to Django 1.2 admin's main page. I've been playing with index.html, but features added to this page affect all app pages. Any ideas on what template I'm supposed to use? Thanks loads!! ...

Server side command line queuing

Is it possible to have a server side program that queues and manages processes that are executed at the command line? The project I am working on takes an image from the user, modifies the image then applies it as a texture to a 3D shape. This 3D scene is generated by blender/Cinema 4d at the command line which outputs it as an image. I...

How to prevent my site page to be loaded via 3rd party site frame of iFrame

How can I find out that my page is embedded as a frame to other site during page loading? I guess referrer request header can't help me here? Thanks. ...

Removing Item From List - during iteration - what's wrong with this idiom ?

As an experiment, I did this: letters=['a','b','c','d','e','f','g','h','i','j','k','l'] for i in letters: letters.remove(i) print letters The last print shows that not all items were removed ? (every other was). IDLE 2.6.2 >>> ================================ RESTART ================================ >>> ['b', 'd', 'f', 'h'...

python read utf8 text file problem

I have a problem with python about reading and print utf8 text file. I have a test.txt in utf8 encoding without BOM. This file has two characters in it: 大声 The first character "大" is Chinese and the second "声" is Japanese. Now, When I use Ulipad (a python editor) to run the following code to read the txt file, and print these two cha...

Getting Omni complete to work on vim 7.2 on windows

Hi, I am trying to use the Omni complete feature with gVim 7.2 but on windows I keep getting an error that says Error: require vim compiled with +python E117: unknown function: pythoncomplete#complete seems like it might be because gvim 7.2 is compiled with 2.4 and I have 2.5 installed. I have downloaded the 2.5 compiled binaries from...

Sorting a string in array, making it sparsely populated.

For example, say I have string like: duck duck duck duck goose goose goose dog And I want it to be as sparsely populated as possible, say in this case duck goose duck goose dog duck goose duck What sort of algorithm would you recommend? Snippets of code or general pointers would be useful, languages welcome Python, C++ and extra k...

How to turn a list of tuples into a string?

I have a list of tuples that I'm trying to incorporate into a SQL query but I can't figure out how to join them together without adding slashes. My like this: list = [('val', 'val'), ('val', 'val'), ('val', 'val')] If I turn each tuple into a string and try to join them with a a comma I'll get something like ' (\'val\, \'val\'), ... ...

Python: UTF16 decoding adds a new blank line on Windows boxes

I'm running into an issue with extra newlines on windows versus *nix platforms. file = open('UTF16file.xml', 'rb') html = file.read().decode('utf-16') file.close() regexp = re.compile(self.originalurl, re.S) (html, changes) = regexp.subn(self.newurl, html) file = open('UTF16file-regexed.xml', 'w+') file.write(html.encode('utf-16')) f...

Speed up bitstring/bit operations in Python?

I wrote a prime number generator using Sieve of Eratosthenes and Python 3.1. The code runs correctly and gracefully at 0.32 seconds on ideone.com to generate prime numbers up to 1,000,000. # from bitstring import BitString def prime_numbers(limit=1000000): '''Prime number generator. Yields the series 2, 3, 5, 7, 11, 13, 17, 19,...

python and objc bridge in an existing application

hi, I resently started programming in objc and I was wandering how can I use python code in an existing objc application. I found some threads in this site and some others but they didn't help me at all. What I want to do is to take the SpotlightAPI found in apple's developer website and use the results to process them with python code. ...

Compiling ODE on windows without Visual Studio (for PyODE)

I'm new to compiling programs written by someone else, so I hope I'm not missing anything obvious. What I am really trying to do is install PyODE, and I think I managed that just fine, but when running the PyODE examples I get an error: Traceback (most recent call last): File "C:\Python26\pyode-examples\tutorial3.py", line 12, in <mo...

How can I unit test django messages?

In my django application, I'm trying to write a unit test that performs an action and then checks the messages in the response. As far as I can tell, there is no nice way of doing this. I'm using the CookieStorage storage method, and I'd like to do something similar to the following: response = self.client.post('/do-something/',...

In Python, how to use a C++ function which returns an allocated array of structs via a ** parameter?

I'd like to use some existing C++ code, NvTriStrip, in a Python tool. SWIG easily handles the functions with simple parameters, but the main function, GenerateStrips, is much more complicated. What do I need to put in the SWIG interface file to indicate that primGroups is really an output parameter and that it must be cleaned up with d...

Confusion Matrix with number of classified/misclassified instances on it (Python/Matplotlib)

I am plotting a confusion matrix with matplotlib with the following code: from numpy import * import matplotlib.pyplot as plt from pylab import * conf_arr = [[33,2,0,0,0,0,0,0,0,1,3], [3,31,0,0,0,0,0,0,0,0,0], [0,4,41,0,0,0,0,0,0,0,1], [0,1,0,30,0,6,0,0,0,0,1], [0,0,0,0,38,10,0,0,0,0,0], [0,0,0,3,1,39,0,0,0,0,4], [0,2,2,0,4,1,31,0,0,0,...