python

Best Python / Django books for Java developers?

I am interested in learning Python and Django. Are there any books that you would recommend especially to Java / JavaEE developers? I already know Dive into Python (by Mark Pilgrim) and the Book of Django (although I think the latter expects readers to already know Python). Cheers! ...

PUT Variables Missing between Python and Tomcat

I'm trying to get a PUT request from Python into a servlet in Tomcat. The parameters are missing when I get into Tomcat. The same code is happily working for POST requests, but not for PUT. Here's the client: lConnection = httplib.HTTPConnection('localhost:8080') lHeaders = {"Content-type": "application/x-www-form-urlencoded", ...

Rookie Python-questions [closed]

Hey! Is it possible to make python run on your homepage? I know, this is a really stupid question but please don't pick on me for my stupidity :) If it is possible, how? Do you have to upload/install the executing part of Python to you website using FTP? or...? Edit: Just found out my provider does not support python and that shell ac...

Recommendation for click/event tracking mechanisms (python, django, celery, mongo etc)

I'm looking into way to track events in a django application (events would generally be clicks tied to a specific unique user id). These events would essentially contain an event type like "click" and then each click event would be assigned to a unique id (many events can go to one id) and each event would have a data set including item...

Locality Sensitive Hashing - finding probabilities and values for R

Thanks to those who've answered my previous questions and gotten me this far. I have a table of about 25,000 vectors, each with 48 dimensions, with values ranging from 0-255. I am attempting to develop a Locality Sensitive Hash (http://en.wikipedia.org/wiki/Locality-sensitive_hashing) algorithm for finding a near neighbor or closest ne...

Converting a Mercurial (hg) repository to Git on Windows (7)

I'm really quite frustrated at this point. I have an existing hg repository that has months of coding history in it, and I want to get this into a private Github repository so I can work on it from there. Unfortunately I use Windows and I can't seem to find any way to convert the repository that I can actually get to work properly. Pract...

I cannot search sent emails in Gmail with Python

Hello everyone, I am trying to search for messages in the Sent (actually i care for both) but I only get incoming messages. For the time being i have imap_conn.select() str_after = after.strftime('%d-%b-%Y') typ, msg_ids = imap_conn.search('UTF-8','SINCE',str_after) Which gives equivalent results with this imap_conn.select('INBOX') ...

Analize programatically (python) Symbian v9 E32Image file

I'm trying to analyze programatically (python) a Symbian v9 Logical Device Driver (LDD zlib deflated). I'm able to read E32ImageHeader, but I can't decompress de code section. I always get "zlib.error: Error -3 while decompressing data: invalid block type" import zlib import struct full = "" f = open("c:\\file.ldd","rb") part...

SQLAlchemy and max_allowed_packet problem

Due to the nature of my application, I need to support fast inserts of large volumes of data into the database. Using executemany() increases performance, but there's a caveat. For example, MySQL has a configuration parameter called max_allowed_packet, and if the total size of my insert queries exceeds its value, MySQL throws an error. ...

Way to Treat Python single vals and lists of vals identically?

Hello, I'm running into this problem often: I'm creating a function that needs to perform a series of operations on a value, whether that value be a single value or a list of values. Is there an elegant way to do this: def convert_val(val): do a series of things to each value, whether list or single val return answer or list of...

How to make non-square edges in Tkinter?

In order to make one of my programs more aesthetically pleasing I'm using images to create the boarders, however I want to create a non square boarder so the program looks kinda like this ___________ / / /__________/ How should I go about this? This is on windows 7, btw. Edit: A tried to make a pseudo-edge using tra...

Is there a list of 3rd party Python 3 libraries?

More and more libraries are being ported to Python 3, and I suspect the changes will happen more and more rapidly as time goes on. However, as a non-newbie to Python, there are quite a few 3rd party libraries I use (matplotlib, pygame, pyGTK, Tkinter, among others). I know I should just be able to go to their site(s) to find out if they ...

Google App Engine: Redirect to RequestHandler

Hello, I just started with Google App Engine using python and I was following a tutorial and writing my own little app to get familiar the webapp framework. Now I just noticed the tutorial does the following self.redirect('/'). So that got me wondering: is there a way to redirect to a handler instead of a hardcoded path? Thought that mi...

How to crop gtk pixbufs

I've got a gtk - pixbuf out of an svg and want to crop this to a specific size at specific coordinates. Anyone has an easy possible solution for that ? ...

ObjectListView Flickers/Flashes when adding a new list object

When I update my objectListView list it flickers/flashes white, is this normal behaviour or can it be prevented. The list gets updated around every 1-5 seconds using the AddObject method if that makes any difference. ...

Can't communicate via socket on Mac OS X

I'm working on some software that consists of a server and clients on one machine that communicate via local sockets. The server (written in Java) opens a java.net.ServerSocket on port 9000, and the clients (in either Java or Python) have to connect to localhost:9000 to communicate. In Windows and Linux, this works fine. On Mac OS X (...

Why does this Python (Django) code eat up memory?

Why does this code eat up memory? When I run it it slowly consumes more memory with every loop, and I have something like 300000 loops. I'm using Windows, and Python 2.6. def LoadVotes(self): old_votes=Votes.objects.all() amount=old_votes.count() print 'Amount of votes is: ' + str(amount) c=0 for row in old_votes: ...

Trouble with syntax - if/else and raw_input()

Okay, so the answer is probably obvious, but I don't know the correct way to get the program to respond differently depending on what the user types. octopusList = {"first": ["red", "white"], "second": ["green", "blue", "red"], "third": ["green", "blue", "red"]} squidList = ["first", "second", "third"] squid = r...

Validate Email Header in Python

I have a RegEx for validating email addresses, but I'm really looking to validate a whole From header. Any of these would be valid: [email protected] <[email protected]> My Name <[email protected]> Is there anything out there that would validate these as valid from headers? I'm going to look in the smtp library :) ...

How can we properly implement Python bindings of subclassed C++ objects?

I'm having an issue with a rather intricate interaction of C++ and Python that I'm hoping the community can help me with. If my explanation doesn't make sense, let me know in the comments and I'll try to clarify. Our C++ code base contains a parent classes called "IODevice" which is a parent to other classes such as "File" and "Socket"...