python

Yahoo Chat in Python

I'm wondering how the best way to build a way to interface with Yahoo Chat is. I haven't found anything that looks incredibly easy to do yet. One thought it to build it all from scratch, the other thought would be to grab the code from open source software. I could use something like zinc, however, this maybe more complex than it need...

2D vector projection in Python

The code below projects the blue vector, AC, onto the red vector, AB, the resulting projected vector, AD, is drawn as purple. This is intended as my own implementation of this Wolfram demonstration. Something is wrong however and I can really figure out what. Should be either that the projection formula itself is wrong or that I mistake...

Automatically pressing a "submit" button using python

Hi, The bus company I use runs an awful website (Hebrew,English) which making a simple "From A to B timetable today" query a nightmare. I suspect they are trying to encourage the usage of the costly SMS query system. I'm trying to harvest the entire timetable from the site, by submitting the query for every possible point to every poss...

Sort a list of strings based on regular expression match or something similar

I have a text file that looks a bit like: random text random text, can be anything blabla %A blabla random text random text, can be anything blabla %D blabla random text random text, can be anything blabla blabla %F random text random text, can be anything blabla blabla random text random text, %C can be anything blabla blabla When I ...

Running both python 2.6 and 3.1 on the same machine

Hi there, I'm currently toying with python at home and I'm planning to switch to python 3.1. The fact is that I have some script that use python 2.6 and I can't convert them since they use some module that aren't available for python 3.1 atm. So I'm considering installing python 3.1 along my python 2.6. I only found people on internet t...

How do you subclass the file type in Python?

I'm trying to subclass the built-in file class in Python to add some extra features to stdin and stdout. Here's the code I have so far: class TeeWithTimestamp(file): """ Class used to tee the output of a stream (such as stdout or stderr) into another stream, and to add a timestamp to each message printed. """ def _...

Apache: VirtualHost with [PHP|Python|Ruby] support

Hi there, I am experimenting with several languages (Python, Ruby...), and I would like to know if there is a way to optimize my Apache Server to load certain modules only in certain VirtualHost, for instance: http://myapp1 <- just with Ruby support http://myapp2 <- just with Python support http://myapp3 <- just with Php support ... ...

shlex alternative for Java

Is there a shlex alternative for Java? I'd like to be able to split quote delimited strings like the shell would process them. For example, if I'd send : one two "three four" and perform a split, I'd like to receive the tokens onetwothree four ...

Want to write an eBook collection manager in Python. What do I need to learn?

Hello everyone, I have been teaching myself the rudiments of Python and have reached a stage where I would like to tackle a project of increasing complexity in order to "scratch an itch". I have a large eBook collection (several gigabytes, organized in folders according to topic, mostly .pdf files with the occasional .djvu, .html, and ...

Does creating separate functions instead of one big one slow processing time?

I'm working in the Google App Engine environment and programming in Python. I am creating a function that essentially generates a random number/letter string and then stores to the memcache. def generate_random_string(): # return a random 6-digit long string def check_and_store_to_memcache(): randomstring = generate_random_strin...

What is the Pythonic way to write this loop?

for jr in json_reports: jr['time_created'] = str(jr['time_created']) ...

Play mp3 using Python, PyQt, and Phonon

I been trying all day to figure out the Qt's Phonon library with Python. My long term goal is to see if I could get it to play a mms:// stream, but since I can't find an implementation of this done anywhere, I will figure that part out myself. (figured I'd put it out there if anyone knew more about this specifically, if not no big deal...

How would you adblock using Python?

I'm slowly building a web browser in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser. How would you go about it using python/PyQt4? [edit1] Ok. I think i've setup Privoxy. I haven't setup any additional filters and it seem...

Running JSON through Python's eval()?

Best practices aside, is there a compelling reason not to do this? I'm writing a post-commit hook for use with a Google Code project, which provides commit data via a JSON object. GC provides an HMAC authentication token along with the request (outside the JSON data), so by validating that token I gain high confidence that the JSON dat...

python csv question

Hi all, i'm just testing out the csv component in python, and i am having some trouble with it. I have a fairly standard csv string, and the default options all seems to fit with my test, but the result shouldn't group 1, 2, 3, 4 in a row and 5, 6, 7, 8 in a row? Thanks a lot for any enlightenment provided! Python 2.6.2 (r262:71600,...

Missing datetime.timedelta.to_seconds() -> float in Python?

I understand that seconds and microseconds are probably represented separately in datetime.timedelta for efficiency reasons, but I just wrote this simple function: def to_seconds_float(timedelta): """Calculate floating point representation of combined seconds/microseconds attributes in :param:`timedelta`. :raise ValueError:...

Get brief human-readable info about XRI OpenID with Python?

I'd like to be able to tell to the site visitor that comes with his/her OpenID: you are using your XYZ id for the first time on mysite - please create your sceen name, where XYZ is a nice token that makes sense. For example - XYZ could be the provider name. I'd like to find a solution that works for OpenID as defined in the standard - i...

How to handle back and forward buttons in the hildon.Seekbar?

The hildon.Seekbar widget consists of a scale widget and two buttons. What signals does the widget send when the buttons are clicked or how could I find out? Is there a way to monitor all signals/events that a widget sends in PyGTK? ...

using registered com object dll from .NET

Hi all, I implemented a python com server and generate an executable and dll using py2exe tool. then I used regsvr32.exe to register the dll.I got a message that the registration was successful. Then I tried to add reference to that dll in .NET. I browsed to the dll location and select it, but I got an error message box that says: A ref...

Best way to programatically create image

Hi, I'm looking for a way to create a graphics file (I don't really mind the file type, as they are easily converted). The input would be the desired resolution, and a list of pixels and colors (x, y, RGB color). Is there a convenient python library for that? What are the pros\cons\pitfalls? Udi ...