python

Understanding CGI and SQL security from the ground up

This question is for learning purposes. Suppose I am writing a simple SQL admin console using CGI and Python. At http://something.com/admin, this admin console should allow me to modify a SQL database (i.e., create and modify tables, and create and modify records) using an ordinary form. In the least secure case, anybody can access htt...

running pdb from within pdb

I'm debugging an script that I'm writing and the result of executing a statement from pdb does not make sense so my natural reaction is to try to trace it with pdb. To paraphrase: Yo dawg, I like python, so can you put my pdb in my pdb so I can debug while I debug? ...

Another floating point question

I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that exe...

youtube python api gdata.service. requesterror

i have the following code which is trying to add a set of videos into a youtube play list import urllib,re import gdata.youtube import gdata.youtube.service class reddit(): def __init__(self, rssurl ='http://www.reddit.com/r/chillmusic.rss' ): self.URL = rssurl self._downloadrss() def _downloadrss(self): ...

Is there an open source cross-platform push server?

I'm currently in need of a (preferably open-source) free push server, that supports both linux and windows. I need something similar to the Ajax Push Engine, but that project unfortunatelly does not work on windows (I could use a virtual machine, but that's not what I'm looking for). I need to be able to push information to/from a pytho...

Help with pyHook error.

Hey, I'm trying to make a global hotkey with pyhook in python that is supposed to work only with the alt key pressed. here is the source: import pyHook import pythoncom hm = pyHook.HookManager() def OnKeyboardEvent(event): if event.Alt == 32 and event.KeyID == 49: print 'HERE WILL BE THE CODE' hm.KeyDown = OnKeyboardEve...

Character Sets explained for Dummies!

I don't think i fully understand character sets so i was wondering if anyone would be kind enough to explain it in layman's terms with examples ( for Dummies).I know there is utf8, latin1(ISO 8859-1), ascii ect The more answers the better really. Thank you in advance;-) ...

floating point equality in Python and in general

I have a piece of code that behaves differently depending on whether I go through a dictionary to get conversion factors or whether I use them directly. The following piece of code will print 1.0 == 1.0 -> False But if you replace factors[units_from] with 10.0 and factors[units_to ] with 1.0 / 2.54 it will print 1.0 == 1.0 -> True #!...

not getting output from parmiko/ssh command

I am using paramiko/ssh/python to attempt to run a command on a remote server. When I ssh manually and run the command in question, I get the results I want. But if I use the python (co-opted from another thread on this site) below, there is no returned data. If I modify the command to be something more basic like 'pwd' or 'ls' I can the...

Generating very large XML files in Python?

Does anyone know of a memory efficient way to generate very large xml files (e.g. 100-500 MiB) in Python? I've been utilizing lxml, but memory usage is through the roof. ...

Access Denied when using popen - Python

Hi folks, I'm using popen in order to send a few commands within a Django app. Problem is that I'm getting [Error 5] Access Denied, apparently I have no access to cmd.exe, which popen seems to use. WindowsError at /test/cmd/ [Error 5] Access is denied: 'C:\WINDOWS\system32\cmd.exe /c dir' I reckon this is because the app sit...

Tricky Python Questions

What are the most 'tricky questions' you came across concerning python (ie during job interview) ? You can also give a sample solution of the problem. Mine : How in one line add to arguments of workers names list their positional numbers ( list=[jon,michael,rob,bill] ). ...

How to find an image within another image using python

I'm trying to use python to determine if one (small) image is within another (large) image. Any suggestions before I take myself completely down the wrong path? /edit: Ok, some ideas: I'm using PIL, and I'm converting each image to the 'P' mode so I can compare each pixel as an integer. I'm trying to implement something like a Boye...

Repoze.bfg or Grok

Hello, I am about to take the head long plunge into Zope land and am wondering which framework would fit my needs better. I have some experience toying around with django and the primary reason I am switching to a zope-based framework is ZPT and also needing to occasionally do things with Plone. Both seem to be well run projects I a...

Where do I put utility functions in my Python project?

I need to create a function to rotate a given matrix (list of lists) clockwise, and I need to use it in my Table class. Where should I put this utility function (called rotateMatrixClockwise) so I can call it easily from within a function in my Table class? ...

How to convert MP3 to WAV in Python

If I have an MP3 file how can I convert it to a WAV file? (preferably, using a pure python approach) ...

Django ORM and PostgreSQL connection limits

I'm running a Django project on Postgresql 8.1.21 (using Django 1.1.1, Python2.5, psycopg2, Apache2 with mod_wsgi 3.2). We've recently encountered this lovely error: OperationalError: FATAL: connection limit exceeded for non-superusers I'm not the first person to run up against this. There's a lot of discussion about this error, speci...

How can I prevent a mod_wsgi django application from repeated reloads?

My mod_wsgi django application seems to keep getting reloaded for the first several requests that the client makes. This is killing my performance After enough requests it seems to settle down, and the application no longer seems to be getting reloaded. Any thoughts on why this is happening and how I can prevent it? (I have the followi...

Specifics of List Membership

How does Python (2.6.4, specifically) determine list membership in general? I've run some tests to see what it does: def main(): obj = fancy_obj(arg='C:\\') needle = (50, obj) haystack = [(50, fancy_obj(arg='C:\\')), (1, obj,), needle] print (1, fancy_obj(arg='C:\\'),) in haystack print needle in haystack if __nam...

Google finance quotes search box

Trying to implement a web service which should have exactly the same function as http://www.google.com/finance the search quotes box when user type the stock name or company name, the right stock name is suggested while typing. my service will using historical information from google finance, so get proper quote name from google is a m...