python

Problems with SQLAlchemy and VirtualEnv

I'm trying to use SQLAlchemy under a virtualenv on OS X 10.5, but cannot seem to get it to load whatsoever. Here's what I've done mkvirtualenv --no-site-packages test easy_install sqlalchemy I try to import sqlalchemy from the interpreter and everything works fine, but if i try to import sqlalchemy from a python script, I get the fol...

webob cookies

I am not able to set cookies using following statements self.request.headers['Cookie'] = 'uniqueid = ',unique_identifier self.request.headers['Cookie'] = 'nickname = ',nickname as self.request.cookies is returning null dictionary in another request. environment is python on google app engine ...

Is there a Perl or Python library for ID3 metadata?

Basically, I've got a bunch of music files yoinked from my brother's iPod that retain their metadata but have those absolutely horrendous four character names the iPod seems to like storing them under. I figured I'd write a nice, quick script to just rename them as I wished, but I'm curious about any good libraries for reading ID3 metada...

Image resizing web service

Does someone know a good web service to resize images ? Either an open source (PHP/Python/Ruby) application, or a company providing a web service api. ...

Python - Print on stdout on a "terminal"

Before starting, I ask you all to apologize for the question. Maybe it is stupid, but I cannot find a solution !!! I am working on a remote machine, I HAVE NO IDEA OF WHAT TYPE !!! My python code, that seems to work, is the one below. The problem is that I am trying to print some outputs on the screen but nothing happens ! I have trie...

run django with xampp on windows

can i run django (Python framework) site with xampp on windows? Please guide me. ...

list() doesn't work in appengine?

i am trying to use set function in appengine, to prepare a list with unique elements. I hit a snag when i wrote a python code which works fine in the python shell but not in appengine + django This is what i intend to do(ran this script in IDLE): import re value=' [email protected], dash@ben,, , [email protected] ' value = value...

Is there an option to configure a priority in memcached? (Similiar to Expiry)

A hashtable in memcached will be discarded either when it's Expired or when there's not enough memory and it's choosen to die based on the Least Recently Used algorithm. Can we put a Priority to hint or influence the LRU algorithm? I want to use memcached to store Web Sessions so i can use the cheap round-robin. I need to give Session...

How to flatten a fish eye picture (with python)?

I've found programs to turn fish eye pictures into flat ones. I'd like to learn the process behind the scenes. Can someone share their knowledge about the technique? ...

How to keep a Python script output window open?

I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can analyze my output. How can I keep it open? ...

Creating dynamic images with WSGI, no files involved

Hello there fellow SOers, I would like to send dynamically created images to my users, such as charts, graphs etc. These images are "throw-away" images, they will be only sent to one user and then destroyed, hence the "no files involved". I would like to send the image directly to the user, without saving it on the file system first. W...

Python C API: how to get string representation of exception?

If I do (e.g.) open("/snafu/fnord") in Python (and the file does not exist), I get a traceback and the message IOError: [Errno 2] No such file or directory: '/snafu/fnord' I would like to get the above string with Python's C API (i.e., a Python interpreter embedded in a C program). I need it as a string, not output to the console...

How do I concatenate files in Python?

I have multiple (between 40 and 50) MP3 files that I'd like to concatenate into one file. What's the best way to do this in Python? Use fileinput module to loop through each line of each file and write it to an output file? Outsource to windows copy command? ...

Python class to merge sorted files, how can this be improved?

Background: I'm cleaning large (cannot be held in memory) tab-delimited files. As I clean the input file, I build up a list in memory; when it gets to 1,000,000 entries (about 1GB in memory) I sort it (using the default key below) and write the list to a file. This class is for putting the sorted files back together. It works on the f...

Why are there extra blank lines in my python program output?

I'm not particularly experienced with python, so may be doing something silly below. I have the following program: import os import re import linecache LINENUMBER = 2 angles_file = open("d:/UserData/Robin Wilson/AlteredData/ncaveo/16-June/scan1_high/000/angles.txt") lines = angles_file.readlines() for line in lines: splitted_lin...

Array division- translating from MATLAB to Python

I have this line of code in MATLAB, written by someone else: c=a.'/b I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are: a: 18x1, b: 25x18, ...

How To Reversibly Store Password With Python On Linux?

First, my question is not about password hashing, but password encryption. I'm building a desktop application that needs to authentificate the user to a third party service. To speed up the login process, I want to give the user the option to save his credentials. Since I need the password to authentificate him to the service, it can't b...

How to put variables on the stack/context in Python

In essence, I want to put a variable on the stack, that will be reachable by all calls below that part on the stack until the block exits. In Java I would solve this using a static thread local with support methods, that then could be accessed from methods. Typical example: you get a request, and open a database connection. Until the re...

PYTHONPATH ignored

Environment: debian 4.0 Python 2.4 My 'project' is installed in: /usr/lib/python2.4/site-packages/project. But I want to use my working copy instead of the installed one which is located in: /home/me/dev/project/src So what I do is: export PYTHONPATH=/home/me/dev/project/src ipython import foo # which is in s...

Showing progress of python's XML parser when loading a huge file

Im using Python's built in XML parser to load a 1.5 gig XML file and it takes all day. from xml.dom import minidom xmldoc = minidom.parse('events.xml') I need to know how to get inside that and measure its progress so I can show a progress bar. any ideas? minidom has another method called parseString() that returns a DOM tree assumi...