python

Python scene change detection

Hi there, I am wondering if anyone has any experience with Python and video processing. Essentially, I would like to know if there are any libraries that would allow me to do scene detection in a video? If not, are there any that can allow me to split the video up into a series of frames and let me mess about with the pixels? Thanks! ...

dictionary and stack in python problem

I have made a dictionary and I put the keys of the dict in a list. My list contains elements like this: s = [((5, 4), 'South', 1), ((4, 5), 'West', 1)] I made a dict from this: child = dict((t[0], t[1]) for t in s) keys = child.keys() print keys The output is : [(4, 5), (5, 4)] Now I need to put (4,5) and (5,4) into stack. What ...

stack problem in python

Possible Duplicate: dictionary and stack in python problem s = [((5, 4), 'South', 1), ((4, 5), 'West', 1)] I want to put the (5,4) and (4,5) in to the stack. stack is already implemented in a file... so I am using : stack = search.Stack() Now I can use push and pop for stack. How to get the (5,4) and (4,5) from the list...

Getting Python's nltk.wordnet module working for Jython.

Hello, I've read through the FAQ for Jython and this post http://stackoverflow.com/questions/471000/jython-and-python-modules but am not sure how I can determine if a module is written purely in C or Python. The problem I'm facing is mentioned here http://old.nabble.com/using-NLTK-in-Jython-td28520926.html Can anyone that has done thi...

python 2.5.1 and supported version of xpath

hey.. trying to figure out how to determine what version of XPath is supported by python 2.4.3/2.5.1 using libxml2dom. in looking through various docs, i must be missing something! basically, i'm considering how/if i can have an XPath function, and use regex within the XPath... i understand the XPath v2.0 supports using regex, so i'm ...

how to create one-to-many relevance on google-app-engine

like one forum has many topic , ths specific is : forum and topic has the same model : class Geo(db.Model): #self = db.SelfReferenceProperty() title = db.StringProperty() link = db.StringProperty() updated = db.DateTimeProperty(auto_now =True) author = db.ReferenceProperty(MyUser) id = db.StringProperty() e...

Python: defining a union of regular expressions

I have a list of patterns like list_patterns = [': error:', ': warning:', 'cc1plus:', 'undefine reference to'] what I want to do is to produce a union of all of them yielding a regular expression that matches every element in list_patterns [but presumably does not match any re not in list_patterns -- msw] re.compile(list_patterns) ...

append tuples to a list

How can I append the content of each of the following tuples (ie, elements within the list) to another list which already has 'something' in it? So, I want to append the following to a list (eg: result[]) which isn't empty: l = [('AAAA', 1.11), ('BBB', 2.22), ('CCCC', 3.33)] Obviously, the following doesn't do the thing: for item in ...

python dictionary problem

output of n is in the form:- ((6,5),'north',1) I am making a dict child for it...in which (6,5) is the key and north and 1 are the values. I need to keep the (6,5) as the key and north as a direction....and I want to keep adding all the values till the while loop continues ...

How do I force matplotlib to write out the full form of the x-axis label, avoiding scientific notation?

Hello, I've created a simple hexbin plot with matplotlib.pyplot. I haven't changed any default settings. My x-axis information ranges from 2003 to 2009, while the y values range from 15 to 35. Rather than writing out 2003, 2004, etc., matplotlib collapses it into 0, 1, 2, ... + 2.003e+03. Is there a simple way to force matplotlib to...

twisted callback function confusion

I'm working on a twisted tutorial just to learn more python and it seems I've ran into a road block here. The doRead() function below is the "callback" of a reactor. What I can't understand is how the except part works. The way I read the code is that if bytes += self.sock.recv(1024) would've caused a block then it will reach the follo...

binary16 in Python

The struct module is useful when you're trying to convert data to and from binary formats. However, recently I came across a file format specification that uses the binary16 floating point format. I looked through the Python documentation, but can't find anything that can convert to and from it. What would be the best way to convert this...

How can I "watch" a file for modification / change?

I would like to invoke my chrome or firefox browser when a file that I specify is modified. How could I "watch" that file to do something when it gets modified? Programmatically it seems the steps are.. basically set a never ending interval every second or so and cache the initial modification date, then compare the date every second, w...

How to make a class field [list] read-only in python?

i have self.some_field = [] in my class Im enquiring is there a way to make this list read-only like a property? ...

design workflow/flowchart representation in python ?

In my web application I have wizards with many next previous buttons and choices ( kind of flow chart with events and options ). Wizard do not run in one go, but may wait for external event, user come later or next day to carry on with that wizard. Currently I am manually writing code ( hard coded ) for each states of a wizard ( or a flo...

how to combine exponents? (x**a)**b => x**(a*b)?

how to simplify exponents in equations in sympy from sympy import symbols a,b,c,d,e,f=symbols('abcdef') j=(a**b**5)**(b**10) print j (a**(b**5))**(b**10) #ans even after using expand simplify # desired output a**(b**15) and if it is not possible with sympy which module should i import in python? edit even if i define 'b' as re...

How do I do this with Django objects.filter?

MYTable.objects.filter( where id = 42, 55, 65, and 55) and it returns a query set ? ...

How would I determine zodiac / astrological star sign from a birthday in Python?

I am building a dating site in Django / Python. I have birthday dates and need to show what the person's Zodiac sign is based on their birthday. Anybody done this before? What would be the most efficient way of accomplishing this? ...

Why doesn't this Proxy server (written in python using asyncore) work?

This proxy server connects to another proxy server which is connected to the internet . The problem with this is that authentication etc works fine but the Server receives only the header from the remote server and not the HTML.How to fix this? please help USER='someUsername' PASS='somePassword' import asyncore import asynchat import ...

problem in dictionary python

I made a dictionary, then split up the values and keys into lists and now its looks like this: keys = [(4,5),(5,6),(4,8)......so on]. values = [('west',1),('south',1).......] Then I made a new dictionary like in this way, final = dict((k,v[0]) for k,v in zip(keys, values)) When I execute -print final - output is in this form... {(4...