python

Python: Detecting the actual text paragraphs in a string

The big mission: I am trying to get a few lines of summary of a webpage. i.e. I want to have a function that takes a URL and returns the most informative paragraph from that page. (Which would usually be the first paragraph of actual content text, in contrast to "junk text", like the navigation bar.) So I managed to reduce an HTML page ...

How to use twisted for downloading a remote file?

I'm relatively new to twisted and I'm planning on using it to create a file downloader. It would accept a file url and a number of parts to download the file. What I have in mind is to split the file into how many parts the user specified and download each parts through deferred and when it is done, all parts gets assembled. But do I n...

List of API commands for Win32api

Hi every one. I recently found the add-on for Python called "win32api". I am very pleased with it.. But only problem is i can't seem to find any lists that list all the possible API calls that you can make from that add-on. I have tried looking through an API reference (http://www.andreavb.com/API_List.html), but most of the commands wer...

GAE - Sharing Authentication Across Apps

Let's say I had a root app and multiple sub-apps. Would it be possible to share authenticated sessions across them? I'm using Google App Engine (Python). ...

Best Twitter Framework for Python on App Engine?

I'm looking to incorporate twitter API features into an app engine project that I'm working on. I'm relatively new to both app engine and python, so I'm wondering what modules/frameworks I should use to most easily incorporate twitter, and to facilitate twitter oauth? I've seen: python-twitter tipfy gaema ...

binary linear programming solver in Python

I have a Python script in which I need to solve a linear programming problem. The catch is that the solution must be binary. In other words, I need an equivalent of MATLAB's bintprog function. NumPy and SciPy do not seem to have such a procedure. Does anyone have suggestions on how I could do one of these three things: Find a Python li...

Common convention for invoking unit tests across a python project?

Is there a standard convention, or even a growing one, around where and how to invoke the tests associated with a project? In many projects, I'm seeing it bundled into a Make, a separate test.py script at the top level of the project, etc to do the work.  I looked around for some common thing with setup.py, but didn't spot anything ther...

Python on OSX Setup Help for use with Google App Engine

When I type which python, I get the following result: /Library/Frameworks/Python.framework/Versions/Current/bin/python when I type "type -a python": python is /Library/Frameworks/Python.framework/Versions/Current/bin/python python is /Library/Frameworks/Python.framework/Versions/2.6/bin/python python is /Library/Frameworks/Python.fram...

Hadoop Streaming Multiline Input

I'm using Dumbo for some Hadoop Streaming jobs. I have a bunch of JSON dictionaries each containing an article (multiline text) and some meta data. I know Hadoop performs best when give large files, so I want to concat all the JSON dictionaries into a single file. The problem is that I don't know how to make Hadoop read each dictionar...

GAE + Python vs Webfaction + Python + django - for a relative new dev

Basically I have a webfaction space (assume for the purposes of this question that its free). I am trying to learn python by created some simple web applications on Google App Engine using Eclipse + Pydev for development. So far I have some basic functionality working in App Engine, though I have had some frustration with some library ...

Hierarchical Task Network Planner in Python

Is anyone aware of a hierarchical task network planner implemented in Python or Java? I've found a few open source systems, but they're all seemingly dead projects and haven't been maintained in years. ...

Simple list comprehension (Python)

I want a dictionary of files: files = [files for (subdir, dirs, files) in os.walk(rootdir)] But I get, files = [['filename1', 'filename2']] when I want files = ['filename1', 'filename2'] How do I prevent looping through that tuple? Thanks! ...

How to properly columnize tables in a Django template.

I am currently trying to break a list of people (aprox 20 to 30 items) into a table with 4 columns. Here is my current code. <table> {% for person in people %} {% cycle "<tr><td>" "<td>" "<td>" "<td>" %} {{ person }} {% cycle "</td>" "</td>" "</td>" "</td></tr>" %} {% endfor %} </table> Obviously, this is pretty ugly, ...

pydev importerror: no module named thread, debugging no longer works after pydev upgrade

My Eclipse 3.6 /PyDev setup just did a pydev upgrade to 1.6.0.2010071813 and debugging no longer works. My default python interpreter is 3.1 although I doubt that matters. Until the Eclipse upgrade of pydev, it was working very nicely. ...

Really weird Cookie header behaviour? - Cookies

Hi folks, I'm using Firefox 3.6.8 for these tests. I'm setting a cookie within the response headers of my web app using: Set-Cookie: session=7878dfdsfjsdf89sd89f8df9 This does not seem to override the session Cookie. When a request is performed instead Firefox even sends duplicate cookies: Cookie: session=7d75cd8f55895cbccb0d31e...

Why do I get this error in MySQL?

import MySQLdb import random db = MySQLdb.connect (host = "localhost", user = "python-test", passwd = "python", db = "python-test") cursor = db.cursor() var = .3 sql = "INSERT INTO RandomInt (RAND) VALUES (var)" # RandomInt is the name of the table and Rand is the Column Name cursor.execute(sql) db.c...

Facebook wall writing application

I was wondering if i could possible write an app, that could be a list of all my friends and just simply posting a message to their walls on the friends i select. Not a message, a wall post. So it appears that i went to their wall and wrote a message, they have no idea that an app is pushing the message to them. also could it be written...

Python script to do a GET request on 2 urls in a cron job

I need a python script to perform a GET request on 2 urls. I will use these scripts in a cron job on my ubuntu server. The catch is, the 2 calls have to happen sequentially because the first GET request to Url#1 might take up to 1 minute or so to complete. For the cron job, I want it to run every 30 minutes. ...

Control access to parts of a system, but also to certain pieces of information

This is a tricky question, we've been talking about this for a while (days) and haven't found a convincingly good solution. This is the situation: We have users and groups. A user can belong to many groups (many to many relation) There are certain parts of the site that need access control, but: There are certain ROWS of certain tables...

Python's mysqldb obscure documentation

There are many escape functions in the Python module mysqldb whose documentation I don't understand, and my efforts at looking them up have revealed nothing. >>> print _mysql.escape.__doc__ escape(obj, dict) -- escape any special characters in object obj using mapping dict to provide quoting functions for each type. Returns a SQL litera...