python

Acesss properties of navigation buttons in wxPython's wxWizard

Hi, I'm using the wxWizard widget in wxPython. Is there any way I could change the text of the next button on a page? Can i change the visibility of the navigation buttons on any page? Can I enable/disable the navigation buttons? I tried looking for answers to these questions on the wxPython site but it doesn't seem to be documented. ...

[Python] name 'OptionGroup' is not defined

This error is done strictly by following examples found on the docs. And you can't find any clarification about it anywhere, be it that long long docs page, google or stackoverflow. Plus, reading optparse.py shows OptionGroup is there, so that adds to the confusion. Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) >>> from optparse imp...

Finding Top Twitter Friends Using Python

What's the best way to find someone's top friends on twitter? I'm trying to figure out a way to see who they interact with the most, but I am not sure what the best way is of doing this. Also, there are obvious things to check (is the username following that person, etc etc). I imagine someone else has thought about this, so I am try...

Distinguishing between broadcasted messages and direct messages

How can I distinguish between a broadcasted message and a direct message for my ip? I'm doing this in python. ...

What are the implications of running python with the optimize flag?

I cannot seem to find a good simple explanation of what python does differently when running with the -O or optimize flag. ...

Matching id's in BeautifulSoup

Hello, I'm using BeautifulSoup - python module. I have to find any reference to the div's with id like: 'post-#'. For example: <div id="post-45">...</div> <div id="post-334">...</div> How can I filter this? html = '<div id="post-45">...</div> <div id="post-334">...</div>' soupHandler = BeautifulSoup(html) print soupHandler.findAll('d...

Does a multithreaded crawler in Python really speed things up?

Was looking to write a little web crawler in python. I was starting to investigate writing it as a multithreaded script, one pool of threads downloading and one pool processing results. Due to the GIL would it actually do simultaneous downloading? How does the GIL affect a web crawler? Would each thread pick some data off the socket, the...

Infinite loop when adding a row to a list in a class in python3

I have a script which contains two classes. (I'm obviously deleting a lot of stuff that I don't believe is relevant to the error I'm dealing with.) The eventual task is to create a decision tree, as I mentioned in this question. Unfortunately, I'm getting an infinite loop, and I'm having difficulty identifying why. I've identified ...

Python Instance Variable as Default Parameter

Hello, I have am writing a Python function that takes a timeout value as a parameter. Normally, the user will always use the same timeout value, but on occasion he may want to wait slightly longer. The timeout value is stored as a class instance variable. I want to use the class' timeout instance variable as the default parameter. C...

Python Sets vs Lists

In Python, which data structure is more efficient/speedy? Assuming that order is not important to me and I would be checking for duplicates anyway, is a Python set slower than a Python list? ...

Howto install distribute for Python 3

I am trying to install distribute using ActivePython 3.1.2 on Windows. Running python distribute_setup.py as described on the cheese shop give me: No setuptools distribution found running install Traceback (most recent call last): File "setup.py", line 177, in scripts = scripts, File "C:\Dev\Python_x86\3.1\lib\distutils\c...

Django Grouping Query

I have the following (simplified) models: class Donation(models.Model): entry_date = models.DateTimeField() class Category(models.Model): name = models.CharField() class Item(models.Model): donation = models.ForeignKey(Donation) category = models.ForeignKey(Category) I'm trying to display the total number of items, p...

Sending and receiving async over multiprocessing.Pipe() in Python

I'm having some issues getting the Pipe.send to work in this code. What I would ultimately like to do is send and receive messages to and from the foreign process while its running in a fork. This is eventually going to be integrated into a pexpect loop for talking to interpreter processes. from multiprocessing import Process, Pipe fro...

Excel CSV into Nested Dictionary; List Comprehensions

heya, I have a Excel CSV files with employee records in them. Something like this: mail,first_name,surname,employee_id,manager_id,telephone_number [email protected],john,smith,503422,503423,+65(2)3423-2433 [email protected],george,brown,503097,503098,+65(2)3423-9782 .... I'm using DictReader to put this into a nested dictionary: import csv g...

Voice Stress Analysis in Python

I'm interested in playing with this, anyone know of any code for this already existing? or what libraries would be useful to get started on something like this? ...

How to generate a <ul><li> tree without recursive using python or other language ??

class tree: def __init__(self, name='a', childs=[]): self.name = name self.childs = childs output: <ul> <li> Introduction <ul> <li>Sub Intro</li> </ul> </li> <li>Module 1</li> </ul> Sorry, my English is poor. ...

Creating a new workbook in Excel from Python breaks

I am trying to use the stock standard win32com approach to drive Excel 2007 from Python. However, when I try to create a new workbook, things go pear-shaped: Python 2.6.4 (r264:75706, Nov 3 2009, 13:23:17) [MSC v.1500 32 bit (Intel)] on win32 ... >>> import win32com.client >>> excel = win32com.client.Dispatch("Excel.Application") >>> w...

How do you set the image attributes using PIL?

I'm using PIL. I tried using : img.info = {'Buyer':'Text','Copyright':'Text2'} This is not working. Is there an alternate way to do it? ...

"isnotnan" functionality in numpy, can this be more pythonic?

Hello Everybody, I need a function that returns non-NaN values from an array. Currently I am doing it this way: >>> a = np.array([np.nan, 1, 2]) >>> a array([ NaN, 1., 2.]) >>> np.invert(np.isnan(a)) array([False, True, True], dtype=bool) >>> a[np.invert(np.isnan(a))] array([ 1., 2.]) Python: 2.6.4 numpy: 1.3.0 Please share...

Phase correlation

How can rotation angle be determined by phase correlation(using fft) of 2 images? The algorithm given in http://en.wikipedia.org/wiki/Phase_correlation returns linear shift, not angular. It also mentions images have to be converted to log-polar coordinates to compute rotation. How is this conversion achieved in python? And post conversio...