python

Download multiple pages concurrently?

Hello I'd like to write a script in Python that can grab url's from a database, and download web pages concurrently to speed things instead of waiting for each page to download one after the other. According to this thread, Python doesn't allow this because of something called Global Interpreter Lock that prevents lauching the same scr...

Python: can you tell the name of the calling shell?

I have a python script that is always called from a shell, which can be either zsh or bash. How can I tell which one called the script? ...

How to shutdown cherrypy from within?

I am developing on cherrypy, I start it from a python script. For better development I wonder what is the correct way to stop cherrypy from within the main process (and not from the outside with ctrl-c or SIGTERM). I assume I have to register a callback function from the main application to be able to stop the cherrypy main process fro...

Python/C++ Binding Library comparison

I feel as though this question is a duplicate, but I haven't found one on the subject (specifically) yet so I'll ask anyway: What Python/C++ binding libraries would you recommend and why? In addition, what has been your experience using it or any others you have tried? Also, what binding features do they contain and has your use of them...

Rhythmbox: how do I access the 'rating' field of a track through Python script?

I would like the capability to get/set the rating associated with a specific track through a Python. How do I achieve this? ...

Creating a news archive in Django

Hi need some help, I looking to build a news archive in python/django, I have no idea where to start with it though. I need the view to pull out all the news articles with I have done I then need to divide them in months and years so e.g. Sept 09 Oct 09 I then need in the view to some every time a new news article is created for a new...

Identical string return FALSE with '==' in Python, why?

The data string is receive through a socket connexion. When receiving the first example where action variable would = 'IDENTIFY', it works. But when receiving the second example where action variable would = 'MSG' it does not compare. And the most bizarre thing, when I use Telnet instead of my socket client both are being compare succe...

Program new functionality for zoom button on Microsoft Natural Ergonomic Desktop 7000

Hi I just bought a new keyboard and mouse (Microsoft Natural Ergonomic Desktop 7000) and it has a neat little zoom lever in the middle of the keyboard. What I'd like to do is write a little program (in C# or Python, for use on Windows Vista) which makes the zoom button act like a scroll button instead. I have no idea where to start. Wh...

Subclass of webapp.RequestHandler doesn't have a response attribute

Using the below code, my template loads fine until I submit the from, then I get the following error: e = AttributeError("'ToDo' object has no attribute 'response'",) Why doesn't my ToDo object not have a response attribute? It works the first time it's called. import cgi import os from google.appengine.api import users from google...

Cannot access django app through ip address while accessing it through localhost

I have a django app on my local computer. I can access the application from a browser by using the url: http://localhost:8000/myapp/ But I cannot access the application by using the ip of the host computer: http://193.140.209.49:8000/myapp/ I get a 404 error. What should I do? Any suggestions? ...

[Python] Login webpage

Okay well I try to login into facebook using python. but well it doesn't work and I've really no idea why By google I found this result for logging into a website unfortunately it does not work for me... It seems to be that there is going something wrong with the cookies, because facebook says to me that cookies aren't turned on when ...

Embeddable Workflow/BPM Library For Python?

Let's say you are building a Python-based web app that requires some workflow management such as that in jBPM or Windows Workflow Foundation. Is there a library that offers this in the Python world? ...

Python Regular Expressions

How do I include an end-of-string and one non-digit characters in a python 2.6 regular expression set for searching? I want to find 10-digit numbers with a non-digit at the beginning and a non-digit or end-of-string at the end. It is a 10-digit ISBN number and 'X' is valid for the final digit. The following do not work: is10 = re.comp...

Python Auto Importing

I'm coming from a PHP background and attempting to learn Python, and I want to be sure to do things the "Python way" instead of how i've developed before. My question comes from the fact in PHP5 you can set up your code so if you attempt to call a class that doesn't exist in the namespace, a function will run first that will load the cl...

Is there any Python XML parser that was designed with humans in mind?

I like Python, but I don't want to write 10 lines just to get an attribute from an element. Maybe it's just me, but minidom isn't that mini. The code I have to write in order to parse something using it looks a lot like Java code. Is there something that is more user-friendly ? Something with overloaded operators, and which maps element...

POSTing a complex JSON object using Prototype

I'm using Prototype 1.6.1 to create an application under IIS, using ASP and Python. The python is generating a complex JSON object. I want to pass this object to another page via an AJAX request, but the Prototype documentation is a little too cunning for me. Can someone show me an example of how to create an Prototype AJAX.Request th...

How to define [] for class in Python?

Hello. I feel like this question has already been asked and answered, yet I couldn't find anything on-topic, so excuse me if it is so. I want to define the behaviour of [] brackets when applied to class, similar to def []=() construct in ruby, so that calling Python obj['foo'] would actually call some [](self, what) method. How can I do ...

How to get a timestamp older than 1901

I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]). Problem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to eas...

asn.1 parser in C/Python

I am looking for a solution to parse asn.1 spec files and generate a decoder from those. Ideally I would like to work with Python modules, but if nothing is available I would use C/C++ libraries and interface them with Python with the plethora of solutions out there. In the past I have been using pyasn1 and building everything by hand ...

General Command pattern and Command Dispatch pattern in Python

I was looking for a Command pattern implementation in Python... (According to Wikipedia, the command pattern is a design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. ) The only thing I found was Command Dispatch pattern: class Dispatcher: ...