python

What are my options (if any) for MySQL with Python 3?

I recently starting playing around with the new features of Python 3.1 and porting one of my 2.6 apps. I was surprised to find that MySQLdb does not yet support any of the 3.x versions of Python. My app uses MySQL extensively, so, as you can imagine, I didn't get too far! What are my options (if any) for working with MySQL and Python ...

Writing a Faster Python Spider

Hello, I'm writing a spider in Python to crawl a site. Trouble is, I need to examine about 2.5 million pages, so I could really use some help making it optimized for speed. What I need to do is examine the pages for a certain number, and if it is found to record the link to the page. The spider is very simple, it just needs to sort thro...

Python networkx 2D radial plotting

How do you make a graph in networkx such that its layout is 2D, radial, and the edges are plotted in increasing edge lengths or weights? ...

Replace Multiple lines in Jython

Hi Everyone , I have written a small program to replace a set of characters , but i also want two or more replace command in a single program . Apart from it i also want to add an bracket after random set of characters. This is my Program file_read=open('<%=odiRef.getOption("READ")%>/EXPORT.XML','r') file_write=open('<%=odiRef.ge...

Python web application

Hey, I want to create a very simple python web app. I don't need Django or any other web framwwork like that. Isn't there a simpler way to create a web app in python? Thanks ...

Raise unhandled exceptions in a thread in the main thread?

There are some similar questions, but none supply the answer I require. If I create threads via threading.Thread, which then throw exceptions which are unhandled, those threads are terminated. I wish to retain the default print out of the exception details with the stack trace, but bring down the whole process as well. I've considered...

Django edit form based on add form?

I've made a nice form, and a big complicated 'add' function for handling it. It starts like this... def add(req): if req.method == 'POST': form = ArticleForm(req.POST) if form.is_valid(): article = form.save(commit=False) article.author = req.user # more processing ... Now I don'...

No readyReadStandardOutput signal from QProcess

Why do I never get the readyReadStandardOutput signal when I run the following? import os, sys, textwrap from PyQt4 import QtGui, QtCore out_file = open("sleep_loop.py", 'w') out_file.write(textwrap.dedent(""" import time while True: print "sleeping..." time.sleep(1)""")) out_file.close() def started(): p...

how stackless python can be fast for concurrency ?

stackless python didn't take a good usage of multi-core, so where is the point it should be faster than python thread/multiprocessing ? all the benchmark use stackless python tasklet to compare with python thread lock and queue, that's unfair, cause lock always has low efficiency see, if use single thread function call without lock i...

Google Federated Login vs Hybrid Protocol vs Google Data Authentication. Whats's the Difference?

Hi, I am trying to implement Google Authentication in my website, in which I would also be pulling some Google Data using the Google Data API and I am using Google App Engine with Jinja2. My question is, so many ways are mentioned to do it. I am confused between Google Federated Login,Google Data Protocol, Hybrid Protocol. Are these ...

Traversing FTP listing

I am trying to to get all directories' name from an FTP server and store them in hierarchical order in a multidimensional list or dict So for example, a server that contains the following structure: /www/ mysite.com images png jpg at the end of the script, would give me a list such as ['/www/' [...

Fast conversion of numeric data into fixed width format file in Python

What is the fastest way of converting records holding only numeric data into fixed with format strings and writing them to a file in Python? For example, suppose record is a huge list consisting of objects with attributes id, x, y, and wt and we frequently need to flush them to an external file. The flushing can be done with the followi...

How to auto-run a script

Hi everyone, I created a script that will tell me what to wear in the morning based on the weather (ie rain slicker if it will rain, heavy jacket if it will be cold, etc). I have fairly basic programming experience with python and the script works perfectly, but I want to be able to create a file that I can just double-click from my des...

Is there an Open Source Python library for sanitizing HTML and removing all Javascript?

I want to write a web application that allows users to enter any HTML that can occur inside a <div> element. This HTML will then end up being displayed to other users, so I want to make sure that the site doesn't open people up to XSS attacks. Is there a nice library in Python that will clean out all the event handler attributes, <scri...

Google App Engine Application Extremely slow

I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch. Even though it is just a very simple web page, it takes long time and often it times out. Any suggestions to solve this? Note: It is responding fast after the first call. ...

How can a total, complete beginner read source code?

I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML. I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for? Thanks. EDIT: Sorry guys, I forgot to me...

How to create a zip archive of a directory in python?

How can I create a zip archive of a directory structure in Python? ...

Dealing with URLs in Django

Hey all! So, basically what I'm trying to do is a hockey pool application, and there are a ton of ways I should be able to filter to view the data. For example, filter by free agent, goals, assists, position, etc. I'm planning on doing this with a bunch of query strings, but I'm not sure what the best approach would be to pass along t...

Django: PYTHON_EGG_CACHE, access denied error

Hi! I am deploying my django application on a server, and on last stages I am getting this error: ExtractionError at /admin/ Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is current...

What is the best way to call Java code from Python?

I have a Java class library (3rd party, proprietary) and I want my python script to call its functions. I already have java code that uses this library. What is the best way to achieve this? ...