python

Is there a Cart/Catalog app out there that isnt a full site?

Every solution i come across seems to be a complete store with far too many options and too much functionality. I can write my own cart to get the minimal functionality i need out of the frontend, im just trying to cut out the time writing a complex backend. What im really looking for is something that offers the backend functionality ...

Python GTK adding signal to a combo box

Hi, I create a combo box using PyGTK: fileAttrCombo = gtk.ComboBox(); I want to attach a signal handler for this combo box. This signal handler handles when user change selection in the combo box. What is be the best approach to do this ? ...

is the sender of google-app-engine allow my own gmail..

my gmail is [email protected] i can only use [email protected] in the sender=".." ,yes ?? from google.appengine.api import mail message = mail.EmailMessage(sender="[email protected]", subject="Your account has been approved") message.to = "[email protected]" message.body = """ Dear Albert...

Do you know any style guide for Python?

Do you know any style guide for Python like "Code Like a Pythonista"? I found chapter 2.3.4 of Expert Python Programming very interesting too. ...

I want the actual file name that is returned by a PHP script

I am writing a python script that downloads a file given by a URL. Unfortuneatly the URL is in the form of a PHP script i.e. www.website.com/generatefilename.php?file=5233 If you visit the link in a browser, you are prompted to download the actual file and extension. I need to send this link to the downloader, but I can't send the downl...

How to pick a chunksize for python multiprocessing with large datasets

I am attempting to to use python to gain some performance on a task that can be highly parallelized using http://docs.python.org/library/multiprocessing. When looking at their library they say to use chunk size for very long iterables. Now, my iterable is not long, one of the dicts that it contains is huge: ~100000 entries, with tuples ...

How do I extend a python module? (python-twitter)

What are the best practices for extending a python module -- in this case I want to extend python-twitter by adding new methods to the base API class. I've looked at tweepy, and I like that as well, I just find python-twitter easier to understand and extend with the functionality I want. I have the methods written already, I'm just try...

Memory leak appears only when multiprocessing

I am trying to use python's multiprocessing library to hopefully gain some performance. Specifically I am using its map function. Now, for some reason when I swap it out with its single processed counterpart I don't get any memory leaks over time. But using the multiprocessing version of map causes my memory to go through the roof. For t...

python operation not permitted (graphtecprint)

I'm running a python program. When it get's to these lines: f = open("/dev/bus/usb/007/005", "r") x = fcntl.ioctl(f.fileno(), 0x84005001, '\x00' * 256) It fails saying: IOError: [Errno 1] Operation not permitted What could be causing this problem? ...

this is my Receiving Email code,but can't Receiving Email .. (google-app-engine)

import logging, email from google.appengine.ext import webapp from google.appengine.ext.webapp.mail_handlers import InboundMailHandler from google.appengine.ext.webapp.util import run_wsgi_app class LogSenderHandler(InboundMailHandler): def receive(self, message): _subject = message.subject _sender=message.sender ...

class __init__ (not instance __init__)

Here's a very simple example of what I'm trying to get around: class Test(object): some_dict = {Test: True} The problem is that I cannot refer to Test while it's still being defined Normally, I'd just do this: class Test(object): some_dict = {} def __init__(self): if self.__class__.some_dict == {}: se...

Best practices for parsing HTML from Wikipedia for iPhone viewing?

I am building an iPhone Wikipeida game app, that requires modifying the default Wiki HTML a little bit (mostly simplifying the page). So far I am directly downloading the HTML output from en.wikipedia.org/wiki/Article_Foo to a python Google App Engine, and then modify its CSS and HTML structure, cache it, and finally output to iPhone. I...

Using arrays with other arrays in Python.

Trying to find an efficient way to extract all instances of items in an array out of another. For example array1 = ["abc", "def", "ghi", "jkl"] array2 = ["abc", "ghi", "456", "789"] Array 1 is an array of items that need to be extracted out of array 2. Thus, array 2 should be modified to ["456", "789"] I know how to do this, but n...

Pylons - Changing the regular 404 Not Found page to a custom one

How do I change the regular 404 page generated by Pylons to my own custom-made 404 page? Thanks in advance, John ...

Sorting a 2D numpy array by multiple axes

I have a 2D numpy array of shape (N,2) which is holding N points (x and y coordinates). For example: array([[3, 2], [6, 2], [3, 6], [3, 4], [5, 3]]) I'd like to sort it such that my points are ordered by x-coordinate, and then by y in cases where the x coordinate is the same. So the array above should look ...

super() in Python 2.x without args

Trying to convert super(B, self).method() into a simple nice bubble() call. Did it, see below! Is it possible to get reference to class B in this example? class A(object): pass class B(A): def test(self): test2() class C(B): pass import inspect def test2(): frame = inspect.currentframe().f_back cls = frame.[?some...

Source for Names to use in web scraping

Can anyone suggest a good source of names that I can use to help analyze some tables on web pages. The first column of the tables I am scraping have names alone, names and titles or just titles. The names can be as varied as John Smith to Vikram Saksena. I have been poking around for a compiled list of words that can be found in proper...

Problems inserting file data into sqlite database using python

I'm trying to open an image file in python and add that data to an sqlite table. I created the table using: "CREATE TABLE "images" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "description" VARCHAR, "image" BLOB );" I am trying to add the image to the db using: imageFile = open(imageName, 'rb') b = sqlite3.Binary(imageFile.read...

how to scrape html generated by javascript using python?

I want to scrape the html generated by javascript , just like what you can see in Firebug. UPDATE: I've found this article: http://blog.motane.lu/2009/07/07/downloading-a-pages-content-with-python-and-webkit/ which use PyQt to solve the problem and it works well for me. BUT another problem occur: I have to login the website first, bu...

How to run unittest for Django?

I configured properties for my django project under pydev. I can run the django app under pydev or under console window. But I have problems to run unittest under pydev. I cannot run unittest for app under console window either. I guessed it's something related to run configurations of pydev, so I made several trials, but with no succe...