python

Which reactor should i use for qt4?

I am using twisted and now i want to make some pretty ui using qt ...

Why am I getting "'ResultSet' has no attribute 'findAll'" using BeautifulSoup in Python?

So I am learning Python slowly, and am trying to make a simple function that will draw data from the high scores page of an online game. This is someone else's code that i rewrote into one function (which might be the problem), but I am getting this error. Here is the code: >>> from urllib2 import urlopen >>> from BeautifulSoup import B...

django for loop counter break

This is hopefully a quick/easy one. I know a way to work around this via a custom template tag, but I was curious if there were other methods I was over looking. I've created a gallery function of sorts for my blog, and I have a gallery list page that paginates all my galleries. Now, I don't want to show all the photos of each gallery in...

Determining Letter Frequency Of Cipher Text In Python

I am trying to make a tool that finds the frequencies of letters in some type of cipher text. Lets suppose it is all lowercase a-z no numbers. The encoded message is in a txt file I am trying to build a script to help in cracking of substitution or possibly transposition ciphers. Code so far cipher = open('cipher.txt','U').read() cip...

Create zip archive for instant download

In a web app I am working on, the user can create a zip archive of a folder full of files. Here here's the code: files = torrent[0].files zipfile = z.ZipFile(zipname, 'w') output = "" for f in files: zipfile.write(settings.PYRAT_TRANSMISSION_DOWNLOAD_DIR + "/" + f.name, f.name) downloadurl = settings.PYRAT_DOWNLOAD_BASE_URL + "/"...

How to setup twill for python 2.6 on Windows?

I have already downloaded twill 0.9. Also, I have installed easy_install for python 2.6. Now I'm stuck with twill installation. Could you help me to settle the problem? ...

Which template technology should I use with CherryPy?

I'm in the process of building a web application using cherrypy. What template technology do you recommend I use? ...

writing text with diacritic ("nikud", vocalization marks) using PIL (python image library)

writing simple text on an image using PIL is easy. draw = ImageDraw.Draw(img) draw.text((10, y), text2, font=font, fill=forecolor ) however, when I try to write Hebrew punctuation marks (called "nikud" or ניקוד), the characters does not overlap as it should. I guess this question is relevant also to Arabic and other similar lang...

error while i use math.atan in python!

when i do 1/2 in python why does it give me zero?.. even if i coerce it with float(1/2) still i get zero .. why??.. and how can i get around it??.. when i give arctan(1/2) i get 0 as answer.. but when i give arctan(.5) i get correct ans !! ...

Creating a range of dates in Python

Hello, I want to create a list of dates, starting with today, and going back an arbitrary number of days, say, in my example 100 days. Is there a better way to do it than this? import datetime a = datetime.datetime.today() numdays = 100 dateList = [] for x in range (0, numdays): dateList.append(a - datetime.timedelta(days = x)) p...

summer-holiday-programming-club - Looking for examples

This post is related to my older one: summer-holiday-programming-club - Which language suits best?. Please read it first if you don't know about the background of this question. After deciding about a programming language I am now looking for simple examples that can be easily implemented in Python and help to understand basic concepts....

User Authentication And Text Parsing in Python

Well I am working on a multistage program... I am having trouble getting the first stage done.. What I want to do is log on to Twitter.com, and then read all the direct messages on the user's page. Eventually I am going to be reading all the direct messages looking for certain thing, but that shouldn't be hard. This is my code so far ...

How do I wait for an image to load after an ajax call using jquery?

I have a Python script that is doing some manipulation on a JPEG image. I pass some parameters to this script and call it from my HTML page. The script returns an img src="newimage.jpg tag. I know how to wait for the reply from the script but I don't know how to tell when the image is fully loaded (when it is, I want to display it). Wha...

How to tell a panel that it is being resized when using wx.aui

I'm using wx.aui to build my user interface. I'm defining a class that inherits from wx.Panel and I need to change the content of that panel when its window pane is resized. I'm using code very similar to the code below (which is a modified version of sample code found here). My question is: is there a wx.Panel method being called behi...

Why Numpy instead of Python lists?

Is it worth my learning NumPy? I have approximately 100 financial markets series, and I am going to create a cube array of 100x100x100 = 1 million cells. I will be regressing (3-variable) each x with each y and z, to fill the array with standard errors. I have heard that for "large matrices" I should use NumPy as opposed to Python lis...

Python regular expression with [:numeric:]

Hi there, I am having some trouble with Python giving me a result I do not expect. Here is a sample code : number = re.search(" [0-9] ", "test test2 test_ 2 333") print number.groups() number = re.search(" [[:digit:]] ", "test test2 test_ 2 333") print number.groups() In the first block I get an object returned but with nothing in it...

How can I explicitly disable compilation of _tkinter.c when compiling Python 2.4.3 on CentOS 5?

I'm trying to explicitly disable the compilation of the _tkinter module when compiling Python 2.4.3. It's easy enough to do by modifying the makefile but I'd rather just append a configuration option to avoid supplying a patch. I do not understand the complex interplay between Modules/Setup*, setup.py and their contribution to the gener...

Is the Python Imaging Library not available on PyPI, or am I missing something?

easy_install pil results in an error: Searching for pil Reading http://pypi.python.org/simple/pil/ Reading http://www.pythonware.com/products/pil Reading http://effbot.org/zone/pil-changes-115.htm Reading http://effbot.org/downloads/#Imaging No local packages or download links found for pil error: Could not find suitable distribution fo...

OpenOffice.org development with pyUno for Windows—which Python?

At home, on Linux, I've experimented with pyUNO to control OpenOffice.org using Python. I've been using Python 2.6. It all seems to work nicely. Now I thought I would try one of my scripts (run a graphical diff for ODF doc) on Windows. But when I tried to run it, I got: ImportError: No module named uno According to udk: Python UNO Br...

Pylons FormEncode with an array of form elements

I have a Pylons app and am using FormEncode and HtmlFill to handle my forms. I have an array of text fields in my template (Mako) <tr> <td>Yardage</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>${h.text('yardage[]', maxlength=3, size=3)}</td> <td>...