python

Stackless python stopped mod_python/apache from working.

Hello I installed stackless pyton 2.6.2 after reading several sites that said its fully compatible with vanilla python. After installing i found that my django applications do not work any more. I did reinstall django (1.1) again and now im kind of lost. The error that i get is 500: Internal Server Error The server encountered an int...

Does one often use libraries outside the standard ones?

I am trying to learn Python and referencing the documentation for the standard Python library from the Python website, and I was wondering if this was really the only library and documentation I will need or is there more? I do not plan to program advanced 3d graphics or anything advanced at the moment. Edit: Thanks very much for the r...

how can I grab video from usb video capture + dvb device with gstreamer?

Hi, I own a avermedia volar HX usb stick, I want to capture fromthe composite input , but I can't because I'm unable to select the input. I'm using gstreamer with + python, I think I need to use gsttuner select input but I have no experience using gstreamer's interfaces. Could someone post a simple example? Thanks! ...

Piping output of subprocess.call to progress bar

I'm using growisofs to burn an iso through my Python application. I have two classes in two different files; GUI() (main.py) and Boxblaze() (core.py). GUI() builds the window and handles all the events and stuff, and Boxblaze() has all the methods that GUI() calls. Now when the user has selected the device to burn with, and the file to...

Debugging multi-threaded Python with Wing IDE

I'm debugging a multi-threaded Python program with Wing IDE. When I press the pause button, it pauses only one thread. I've tried it ten times and it always pauses the same thread, in my case called "ThreadTimer Thread", while the other threads keep on running. I want to pause these other threads so I could step with them. How do I do t...

Python - Use a Regex to Filter Data

Is there a simple way to remove all characters from a given string that match a given regular expression? I know in Ruby I can use gsub: >> key = "cd baz ; ls -l" => "cd baz ; ls -l" >> newkey = key.gsub(/[^\w\d]/, "") => "cdbazlsl" What would the equivalent function be in Python? ...

django auto entry generation

Hello, I am trying to make an automated database entry generation with Django, whenever I trigger it to happen. For instance, assume I have a such model: class status_entry(models.Model): name = models.TextField() date = models.DateField() status = models.BooleanField() and I have several entries to the model such as: 1 ...

AJAX upload in Python (WSGI) without Flash/Silverlight, with progress bar

I am looking for a pure Javascript/Python upload example, that uses server polling instead of client-side SWF to display upload progress (like the one on rapidshare.com for example) Currently, website is running on the standalone wsgi server included with Werkzeug framework, but may be moved to mod_wsgi if the load increases. I've trie...

How can I check to see if a Python script was started interactively?

I'd like for a script of mine to have 2 behaviours, one when started as a scheduled task, and another if started manually. How could I test for interactiveness? EDIT: this could either be a cron job, or started by a windows batch file, through the scheduled tasks. ...

How to avoid html-escaping in evoque

I try to make my evoque templates color-code a bit, but the html I get is already escaped with lt-gt's I read there should be something like a quoted-no-more class but I haven't been able to find the evoque.quoted package My aim is to not have escaped html coming out of the template, but 'real'. from pygments import highlight from p...

Server push (Comet) in Google App Engine in Python

How can I implement Comet / Server push in Google App Engine in Python? ...

Why can't you add attributes to object in python?

(Written in Python shell) >>> o = object() >>> o.test = 1 Traceback (most recent call last): File "<pyshell#45>", line 1, in <module> o.test = 1 AttributeError: 'object' object has no attribute 'test' >>> class test1: pass >>> t = test1() >>> t.test Traceback (most recent call last): File "<pyshell#50>", line 1, in <modul...

How does one make logging color in Django/Google App Engine?

If one iswriting a Django/ Google App Engine application and would like to have logs that are conveniently conspicuous based on color (i.e. errors in red), how does one set that up? I've copied the helpful solution from this question, but I'm not sure how to integrate it into Django/Google App Engine. I figured one would put the follow...

Small open source project

Hi, I'm starting to work on a Master's in CS right now though my undergrad is in another field. I have never worked on anything other than what I have written myself. I have never even really worked on a group project in college. So what I would like to do now is to start contributing to some open source project, both because it can help...

Python filter a list to only leave objects that occur once

Hello, I would like to filter this list, l = [0,1,1,2,2] to only leave, [0]. I'm struggling to do it in a 'pythonic' way :o) Is it possible without nested loops? ...

What would you call a non-persistent data structure that allows persistent operations?

I've got a class that is essentially mutable, but allows for some "persistent-like" operations. For example, I can mutate the object like this (in Python): # create an object with y equal to 3 and z equal to "foobar" x = MyDataStructure(y = 3, z = "foobar") x.y = 4 However, in lieu of doing things this way, there are a couple of met...

Using Python Mechanize like "Tamper Data"

I'm writing a web testing script with python (2.6) and mechanize (0.1.11). The page I'm working with has an html form with a select field like this: <select name="field1" size="1"> <option value="A" selected>A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> </select> In ...

python: How do I check that multiple keys are in a dict in one go?

I want to do something like: foo = {'foo':1,'zip':2,'zam':3,'bar':4} if ("foo","bar") in foo: #do stuff I'm not sure if its possible but would like to know. :-) ...

How To Clone/Mutate A Model In Django Without Subclassing

'Ello, all. I'm trying to create a model in Django based on - but not subclassing or having a DB relation to - another model. My original model looks something like this: it stores some data with a date/time stamp. class Entry(Model): data1 = FloatField() data2 = FloatField() entered = DateTimeField() I'd also like ...

Is the order of results coming from a list comprehension guarenteed?

When using a list comprehension, is the order of the new list guaranteed in any way? As a contrived example, is the following behavior guaranteed by the definition of a list comprehension: >> a = [x for x in [1,2,3]] >> a [1, 2, 3] Equally, is the following equality guaranteed: >> lroot = [1, 2, 3] >> la = [x for x in lroot] >> lb = ...