python

Database query optimization

Ok my Giant friends once again I seek a little space in your shoulders :P Here is the issue, I have a python script that is fixing some database issues but it is taking way too long, the main update statement is this: cursor.execute("UPDATE jiveuser SET username = '%s' WHERE userid = %d" % (newName,userId)) That is getting called ab...

2 techniques for including files in a Python distribution: which is better?

I'm working on packaging a small Python project as a zip or egg file so that it can be distributed. I've come across 2 ways to include the project's config files, both of which seem to produce identical results. Method 1: Include this code in setup.py: from distutils.core import setup setup(name='ProjectName', version='1.0', ...

I created a Python egg; now what?

I've finally figured out how to create a Python egg and gotten it to work. Now... what do I do with it? How do I use it? How do I ensure that everything was correctly included? (Simple steps please... not just redirection to another site. I've googled, but it's confusing me, and I was hoping someone could explain it in a couple of simple...

extend php with java/c++?

i only know php and i wonder if you can extend a php web application with c++ or java when needed? i dont want to convert my code with quercus, cause that is very error prone. is there another way to extend it? cause from what i have read python can extend it with c++ without converting the python code and use java with jython? ...

parsing xml file with similar tags and different attributes!

I am sorry if this is a repeated question or a basic one as I am new to Python. I am trying to parse the following XML commands so that I can "extract" the tag value for Daniel and George. I want the answer to look like Daniel = 78, George = 90. <epas:property name="Tom">12</epas:property> <epas:property name="Alice">34</epas:property>...

win32com equivalent of xlrd's sheet.ncols

xlrd makes it pretty easy to know what the last column is. is there an easy way using win32com? I have tried using ws.UsedRange.Rows.Count but this doesnt seem to give a correct answer. ...

which language to choose for a LIVE web application?

i want to create not only a web application, but a web application where everything is LIVE. eg. if someone posts a message and then another one replies, then the creator will get on his webpage a notification. and also i want to implement a chat in the web application. i want these features to be implemented using true server-push (n...

Python "string_escape" vs "unicode_escape"

According to the docs, the builtin string encoding string_escape: Produce[s] a string that is suitable as string literal in Python source code ...while the unicode_escape: Produce[s] a string that is suitable as Unicode literal in Python source code So, they should have roughly the same behaviour. BUT, they appear to treat si...

Where can I find good ajax support in Java/Python ?

Hello, I want a framework (or anything) that helps me make rich client guis. I know my server-side, but I don't like programming in ajax, javascript, css etc. Something that wraps the ajax code in some objects/methods with clean syntax, would do the trick. I want to write code in java instead of defining css and html tags. Does Java ...

Output MySQL query results in Django shell

I have the following Django Model which retrieves 3 records from a database. The class below represents a Model within a Django application I'm building. I realize that the parameters taken in by the create_hotspots function are not being used. I just simplified what the code looked like previously for the purposes of explaining my probl...

Why is win32com so much slower than xlrd?

I have the same code, written using win32com and xlrd. xlrd preforms the algorithm in less than a second, while win32com takes minutes. Here is the win32com: def makeDict(ws): """makes dict with key as header name, value as tuple of column begin and column end (inclusive)""" wsHeaders = {} # key is header name, value is column begi...

NTLM authentication in Python

I'm trying to implement NTLM authentication on IIS (Windows Server 2003) from Windows 7 with python. LAN Manager Authentication Level: Send NTLM response only. Client machine and server are in the same domain. Domain controller (AD) is on another server (also running Windows Server 2003). I receive 401.1 - Unauthorized: Access is denied...

What c# equivalent encoding does Python's hash.digest() use ?

I am trying to port a python program to c#. Here is the line that's supposed to be a walkthrough but is currently tormenting me: hash = hashlib.md5(inputstring).digest() After generating a similar MD5 hash in c# It is absolutely vital that I create a similar hash string as the original python program or my whole application will fail....

EOF error using recv in python

I am doing this in my code, HOST = '192.168.1.3' PORT = 50007 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) query_details = {"page" : page, "query" : query, "type" : type} s.send(str(query_details)) #data = eval(pickle.loads(s.recv(4096))) data = s.recv(16384) But I am continually gett...

Generate n-dimensional random numbers in Python

I'm trying to generate random numbers from a gaussian distribution. Python has the very useful random.gauss() method, but this is only a one-dimensional random variable. How could I programmatically generate random numbers from this distribution in n-dimensions? For example, in two dimensions, the return value of this method is essentia...

A means to access my db in python - what is my problem afterall?

I have a remote database (at the moment sqlite, but eventually mysql) that I want to be able to call from a webpage dynamically. Basically to query for data that will populate goog viz charts etc on the page (and possibly images). I have a small, slow server that i can basically run anything on. I've also located the python lib that let...

How do I add space between the ticklabels and the axes in matplotlib?

I've increased the font of my ticklabels successfully, but now they're too close to the axis. I'd like to add a little breathing room between the ticklabels and the axis. ...

Removing minimize/maximize buttons in Tkinter

I have a python program which opens a new windows to display some 'about' information. This window has its own close button, and I have made it non-resizeable. However, the buttons to maximize and minimize it are still there, and I want them gone. I am using Tkinter, wrapping all the info to display in the Tk class. The code so far is...

How do i send a file with sockets in python?

Hi all, I am already familiar with python and socket usage and can send strings of text over these. But how would i go about sending, say, an MP3 file? ...

Python - Launch a Long Running Process from a Web App

I have a python web application that needs to launch a long running process. The catch is I don't want it to wait around for the process to finish. Just launch and finish. I'm running on windows XP, and the web app is running under IIS (if that matters). So far I tried popen but that didn't seem to work. It waited until the child pr...