python

Using Python/Selenium/Best Tool For The Job to get URI of image requests generated through JavaScript?

I have some JavaScript from a 3rd party vendor that is initiating an image request. I would like to figure out the URI of this image request. I can load the page in my browser, and then monitor "Live HTTP Headers" or "Tamper Data" in order to figure out the image request URI, but I would prefer to create a command line process to do thi...

Euclidian Distance Python Implementation

I am playing with the following code from programming collective intelligence, this is a function from the book that calculated eclidian distance between two movie critics. This function sums the difference of the rankings in the dictionary, but euclidean distance in n dimensions also includes the square root of that sum. AFAIK since w...

How does wrapping an unsafe python method (e.g os.chdir) in a class make it thread/exception safe?

In the question How do I "cd" in python, the accepted answer recommended wrapping the os.chdir call in a class to make the return to your original dir exception safe. Here was the recommended code: class Chdir: def __init__( self, newPath ): self.savedPath = os.getcwd() os.chdir(newPath) def __del__( self ): ...

Python __str__: Magic Console

Suppose one decided (yes, this is horrible) to create handle input in the following manner: A user types in a command on the python console after importing your class, the command is actually a class name, the class name's __str__ function is actually a function with side effects (e.g. the command is "north" and the function changes some...

How do I get the value of a property corresponding to a SQLAlchemy InstrumentedAttribute?

Given a SQLAlchemy mapped class Table and an instance of that class t, how do I get the value of t.colname corresponding to the sqlalchemy.org.attributes.InstrumentedAttribute instance Table.colname? What if I need to ask the same question with a Column instead of an InstrumentedAttribute? Given a list of columns in an ORDER BY clause ...

How to read, in a line, all characters from column A to B

Hi, is it possible in Python, given a file with 10000 lines, where all of them have this structure: 1, 2, xvfrt ert5a fsfs4 df f fdfd56 , 234 or similar, to read the whole string, and then to store in another string all characters from column 7 to column 17, including spaces, so the new string would be "xvfrt ert5a" ? Thanks a...

[Resolved]Python socket not receiving anything

I'm trying to receive a variable length stream from a camera with python, but get weird behaviour. This is Python 2.6.4 (r264:75706) on linux(Ubuntu 9.10) The message is supposed to come with a static header followed by the size, and rest of the stream. here is the code from socket import * import array import select HOST = '169.254.0...

Using QFrame to display different panes of information?

I'm trying to get a QFrame to serve as a "display area" for a couple different kinds of information, eg: you click on something in a list view and an info pane shows up in the frame to give you information about it, you click on a different item and a different pane shows up. Having trouble swapping the different frames in and out of t...

What do you wish you'd known about when you started learning Python?

Hello, I've decided to learn Python 3. For those that have gone before, what did you find most useful along the way and wish you'd known about sooner? ...

A server side component for tracking a large number of RSS & Atom feeds

I am looking for an open source component that can help me track a large number of RSS feeds (>> 10K RSS sources). I don't care about the programming language, but it should be something with a simple API where I can add or remove RSS feeds and asynchronously receive notifications every time an RSS is updated. Preferably in Java or Pyt...

wxPython : Problem updating background color of controls

[EDIT - Reduced and re-posted code, restated question] I would like to change the background color of a frame (or panel; whichever makes it work). The problem is that the background color of controls on that frame (or panel) don't have their background color updated until I click on the control (the slider control, specifically). Any i...

Creating a PyBuffer from a C struct

EDIT: Upon re-reading my original question I realized very quickly that it was very poorly worded, ambiguous, and too confusing to ever get a decent answer. That's what I get for rushing out a question at the end of my lunch break. Hopefully this will be clearer: I am trying to expose a simple C structure to Python (3.x) as a PyBuffer s...

Custom distutils commands

I have a library called "example" that I'm installing into my global site-packages directory. However, I'd like to be able to install two versions, one for production and one for testing (I have a web application and other things that are versioned this way). Is there a way to specify, say "python setup.py stage" that will not only ins...

How to install pkg config in windows?

I am trying to do it, but all I can get is some source code that I don't know how to do deal with I downloaded from http://pkgconfig.freedesktop.org/releases/ . Any help? ...

running a system command in a python script

I have been going through "A byte of Python" to learn the syntax and methods etc... I have just started with a simple backup script (straight from the book): #!/usr/bin/python # Filename: backup_ver1.py import os import time # 1. The files and directories to be backed up are specified in a list. source = ['"C:\\My Documents"', 'C:...

Introduction/tutorial to `pkg_resources`

I heard about Distribute's pkg_resources. I want it to organize resources such as images in my project. Is there a good tutorial on how to use it? ...

Komodo - watch variables and execute code while on pause in the program

With c# in the Visual Studio IDE I can pause at anytime a program and watch its variables, inspect whatever I want. I noticed that with the Komodo IDE when something crashes and it stops the flow of the program, I can do exactly the same. But for some reason, it seems that when I try to do the same when I manually pause the program, the ...

Python 2.6 on Debian Lenny. Where should the executable go?

I am building python2.6 from source on Debian Lenny. ( ./configure make make altinstall ) I don't want it to conflict with anything existing, but I want it to be in the default search path for bash. Suggestions? (ps, I'm using a vm, so I can trash it and rebuild.) ...

Help installing cx_Oracle

I'm trying to install the cx_Oracle for Python 2.6, but it is failing. I don't know enough about C or MS Vis. Studio's compiler to even approach fixing it myself. This is what is output on the command line: C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install running install running build running build_ext ...

Python web hosting: Why are server restarts necessary?

We currently run a small shared hosting service for a couple of hundred small PHP sites on our servers. We'd like to offer Python support too, but from our initial research at least, a server restart seems to be required after each source code change. Is this really the case? If so, we're just not going to be able to offer Python host...