python

Submitting queries to, and scraping results from aspx pages using python?

I am trying to get results for a batch of queries to this demographics tools page: http://adlab.microsoft.com/Demographics-Prediction/DPUI.aspx The POST action on the form calls the same page (_self) and is probably posting some event data. I read on another post here at stackoverflow that aspx pages typically need some viewstate and va...

Using an index to recursively get all files in a directory really fast

Attempt #2: People don't seem to be understanding what I'm trying to do. Let me see if I can state it more clearly: 1) Reading a list of files is much faster than walking a directory. 2) So let's have a function that walks a directory and writes the resulting list to a file. Now, in the future, if we want to get all the files in t...

drop table in python with sqlite3

I have question about python and sqlite3. I want to drop a table from within Python. The command cur.execute('drop table if exists tab1') Does not work. cur.executescript('drop table if exists tab1;') does the job. The execute method allows the creation of tables. However, it won't drop them? Is there a reason for this? ...

How important are design patterns in web development?

What are the design patterns that I should be completely familiar with? And what is one easy example that each can be used for? I am a web developer (I use Django, and is familiar with separation of logic), but I work at a Desktop-app company. They are always talking about singletons, and I forget...but it leaves me no clue! ...

super() weirdness in Python 3

I know this has been discussed a number of times before, but there was never an explanation of what's going on "under the hood". Can anyone provide a detailed explanation as to why commenting-in the last line of code causes an error to be raised? I know that that object.__init__ doesn't take any arguments, but why does the code work whe...

Draw a colored sphere from cartesian coordinates in pymol

Hi, I was looking in the wiki how to convert the following information about beads, cartesian coordinates + energy : 23.4 54.6 12.3 -123.5 54.5 23.1 9.45 -56.7 ....... to a draw in pymol that contains for each atom a sphere of radius R, centered on its coordinates, and with color, in a rainbow gradient. Thanks ...

How to read *.wav file in Python?

I need to analyze sound written in a .wav file. For that I need to transform this file into set of numbers (arrays, for example). I think I need to use wave-package. However, I do not know how exactly it works. For example I did the following: import wave w = wave.open('/usr/share/sounds/ekiga/voicemail.wav', 'r') for i in range(w.getnf...

python windows vista/7 uac and copying (only reading) files? permissions/interaction of UAC?

I'm currently making a program for a lan center that scans a users hard drive, and copies/archives certain save game files into a zip and uploads them to a FTP server. But I've created a lot of the program at this point and just had a major issue that I had not tested for spring to mind: How does Vista/7's UAC permissions account for c...

Override delete-function on multi-delete

The following works great when going to the objects adminpage and select delete. The problem is that when using multiselect and deleting multiple items at once it doesn't use my delete-override. I've been looking for a solution but haven't found one so it's time to turn to the masters ;) class Photo(models.Model): name = models.Char...

Copy Table data from one DB to another

For development I find myself needing to copy table information from one table to another quite often. I am just curious what are the easiest solutions to do this for Postgres. I have PGAdminIII but it looks like it really only support the long drawn out Backup/Restore. Is there a python or bash script somewhere or something that I ca...

Is there anything out there that can take screenshots of website content and crop out the layout?

Other ideas are also welcome. I am trying to take an excel file, using python to generate an xml for a javascript html webpage that will essentially display a gallery (or some sort of directory structure). The excel file would be pretty massive, but let us assume time isn't so crucial. So far I can convert the tab delimited version of ...

Subclassing Python dictionary to override __setitem__

I am building a class which subclasses dict, and overrides __setitem__. I would like to be certain that my method will be called in all instances where dictionary items could possibly be set. I have discovered three situations where Python (in this case, 2.6.4) does not call my overridden __setitem__ method when setting values, and inst...

Yahoo OAuth question

Hi, I'm keep getting oauth_problem=consumer_key_unknown error when trying oauth https://api.login.yahoo.com/oauth/v2/get_request_token I'm pretty sure my consumer key is correct because it works locally (Runs via 127.0.0.1). Just keep giving me oauth_problem=consumer_key_unknown when I try it on my server. Any ideas? ...

What is the true difference between a dictionary and a hash table?

I've always used dictionaries. I write in Python. ...

subprocess popen + curl + binary data

The following statement works as expected: os.system("curl --data-binary \@"+input_file_path+" -o "+ file_name +" localhost:30") But when trying it with subprocess.popen: Popen(['curl','--data-binary','\@'+input_file_path, '-o', file_name,'localhost:30'], stdout=PIPE).communicate()[0] Curl seems to hang up(logs into endless loop), ...

Assigning value in a while comparison expression

Hi I was wondering if it was possible to assign a value in the while comparison section of the code. Here is an example of the code currently startIndex = find(target, key, startIndex) while( startIndex != -1): matchesFound += 1 startIndex = find(target, key, startIndex + 1) return matchesFound What I want to do is move the s...

Using Beautiful Soup Python module to replace tags with plain text

Hi All, I am using Beautiful Soup to extract 'content' from web pages. I know some people have asked this question before and they were all pointed to Beautiful Soup and that's how I got started with it. I was able to successfully get most of the content but I am running into some challenges with tags that are part of the content. (I ...

machine readable language for writing notes

I'd like to write notes for class in plain text. I was wondering if there was a markup language for doing this, where I could parse the notes for key terms, titles, page #s etc programmatically with a language such as Ruby or Python. ...

Session in python??

python has session feature or not, if it is there then how can i use this and which library should i take ??? ...

Finding intersections

Given a scenario where there are millions of potentially overlapping bounding boxes of variable sizes less the 5km in width. Create a fast function with the arguments findIntersections(Longitude,Latitude,Radius) and the output is a list of those bounding boxes ids where each bounding box origin is inside the perimeter of the function ar...