python

Using Pylons validate and authenticate_form decorator

The validate and authenticate_form decorators don't seem to play nice together. This is my template: <html> <title>Test</title> <body> ${h.secure_form('/meow/do_post')} <input type="text" name="dummy"> <form:error name="dummy"><br> <input type="submit" name="doit" value="Do It"> ${h.end_form()} </body> </html> And this is the controll...

speeding up parsing of files

the following function parses a CSV file into a list of dictionaries, where each element in the list is a dictionary where the values are indexed by the header of the file (assumed to be the first line.) this function is very very slow, taking ~6 seconds for a file that's relatively small (less than 30,000 lines.) how can I speed it up...

syntax difference between ruby and python?

i wonder if there are tutorials that go through the syntax differences for ruby and python? i have seen a comparison between ruby and php but not between ruby and python. i have looked at both ruby and python but it would be very useful with this side-by-side comparison for deciding which one to choose. thanks ...

Google App Engine: get_or_create()?

Does Google App Engine have an equivalent of Django's get_or_create()? ...

How do I get contents of a Google Wave given the wave id and wavelet id?

I am using the robots api. I have a wave id and wavelet id, and my app's email is added to the wave. How can I simply get the wave (or wavelet's) contents using the python api? ...

What are alternatives to Asterisq's Constellation Framework for actionscript?

i would like to present data in something like Constellation Framework... but without flash what other options are out there? python, html5, javascript would be great, but i have no preference other than no flash (i don't own CS) EDIT: i have found a handful of html5 examples without much source code and infoVis. ...

Getting service unavailable message when sending messages to google xmpp using wokkel

Hi, I made a wokkel (twisted python) bot to send and receive messages from the google xmpp service. Everything (auth, presence) etc works fine. One of the requirements of our project is that we need to send broadcast messages to everyone in the list. Normal messages and replies work fin, but when i send a broadcast message, i get this s...

PGU HTML Renderer can't render most sites

I am trying to make a web browser using pygame. I am using PGU for html rendering. It works fine when I visit simple sites, like example.com, but when I try and load anything more complex that uses an html form, like google, I get this error: UnboundLocalError: local variable 'e' referenced before assignment I looked in the PGU html r...

writing header in csv python with DictWriter

assume I have a csv.DictReader object and I want to write it out as a csv file. How can I do this? I thought of the following: dr = csv.DictReader(open(f), delimiter='\t') # process my dr object # ... # write out object output = csv.DictWriter(open(f2, 'w'), delimiter='\t') for item in dr: output.writerow(item) Is that the best wa...

Python - Blackjack

def showCards(): #SUM sum = playerCards[0] + playerCards[1] #Print cards print "Player's Hand: " + str(playerCards) + " : " + "sum" print "Dealer's Hand: " + str(compCards[0]) + " : " + "sum" compCards = [Deal(),Deal()] playerCards = [Deal(),Deal()] How can i add up the interger element of a list conta...

pyparsing ambiguity

I'm trying to parse some text using PyParser. The problem is that I have names that can contain white spaces. So my input might look like this. First, a list of names: Joe bob Jimmy X grjiaer-rreaijgr Y Then, things they do: Joe A bob B Jimmy X C the problem of course is that a thing they do can be the same as the end of the name: ...

Output being printed in the same line, Py3k

In Python 2.x, I'd write... for i in range(5): print i, ...to get integers from 0 to 4 printed in the same row. How to do that in Python 3.x, since print is a function now? ...

Halting Django's dev server via page request?

I'm looking at writing a portable, light-weight Python app. As the "GUI toolkit" I'm most familiar with — by a wide margin! — is HTML/CSS/JS, I thought to use Django as a framework for the project, using its built-in "development server" (manage.py runserver). I've been banging on a proof-of-concept for a couple hours and the only real...

Python program for NIST randomness equation

There is a recurrence equation on page 1789 of this paper and I need some help making a python program to calculate pi_i. I have no idea what is going on here. Other references:original paper, pages (according to adobe, not the physical pages) 43 and 86 edit and i had already deleted what i wrote because all the answers i got were 0, ...

Python Consume a webservice

Hello i want to create a python application that consume a php nusoap webservice and get the result and save it in database what is the best way to do that using python regards ...

Specifying formatting for csv.writer in Python

I am using csv.DictWriter to output csv files from a set of dictionaries. I use the following function: def dictlist2file(dictrows, filename, fieldnames, delimiter='\t', lineterminator='\n'): out_f = open(filename, 'w') # Write out header header = delimiter.join(fieldnames) + lineterminator out_f.write(header...

Django admin add page, how to, autofill with latest data(0002)+1=0003

When adding a new data, can we automatically add a dynamic default data where the value is previous recorded data(0002)+1=0003 ...

Should I use Python or Assembly for a super fast copy program

As a maintenance issue I need to routinely (3-5 times per year) copy a repository that is now has over 20 million files and exceeds 1.5 terabytes in total disk space. I am currently using RICHCOPY, but have tried others. RICHCOPY seems the fastest but I do not believe I am getting close to the limits of the capabilities of my XP machin...

plotting results of hierarchical clustering ontop of a matrix of data in python

How can I plot a dendrogram right on top of a matrix of values, reordered appropriately to reflect the clustering, in Python? An example is in the bottom of the following figure: http://www.coriell.org/images/microarray.gif I use scipy.cluster.dendrogram to make my dendrogram and perform hierarchical clustering on a matrix of data. H...

HttpError 502 with Google Wave Active Robot API fetch_wavelet()

I am trying to use the Google Wave Active Robot API fetch_wavelet() and I get an HTTP 502 error example: from waveapi import robot import passwords robot = robot.Robot('gae-run', 'http://images.com/fake-image.jpg') robot.setup_oauth(passwords.CONSUMER_KEY, passwords.CONSUMER_SECRET, server_rpc_base='http://www-opensoci...