python

GUI development package

I am new to GUI development. What is the best GUI development package for python on linux (ubuntu being more specific)? ...

URL rewriting question

I have a CGI script (pwyky) that I called index.cgi, put in directory wiki/, and setup Apache to call localhost/wiki/index.cgi when I access localhost/wiki. I'm getting errors when I'm trying to use this application -- it creates a page with links like "http://localhost/wiki/@edit/index", but when I click that link, Apace is trying to s...

Encoding Bytes in Python3

What type of codec is the best to encode binary files what are upload to an app write in Python 3? ...

How can i make windmill to output test report to html or image or some else file ?

Hi ! Windmill is a wonderful framework, but i don't know how to get test reports in some separate file, for example html. I'm new in python, so i can't find out where and what to type to redirect output in file or do some else to get nice report-file. Please, tell me how to do this. ...

Django/Celery can't find importlib

So I just updated django to 1.2.3 and now when I try to run 'python manage.py shell' to work in the django environment, I'm getting the following error. Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2...

Dictionaries in Python

I have a problem. I want to make a dictionary that translates english words to estonian. I started, but don't know how to continue. Please, help. Dictionary is a text document where tab separates english and estonian words. file = open("dictionary.txt","r") eng = [] est = [] while True : lines = file.readline() if lines == "...

Check if value already exists within list of dictionaries?

I don't think this question has been asked in this form on SO before. I've got a Python list of dictionaries, as follows: a = [{ 'main_color': 'red', 'second_color':'blue'}, { 'main_color': 'yellow', 'second_color':'green'}, { 'main_color': 'yellow', 'second_color':'blue'}] I'd like to check whether a dictionary with a particular ke...

How to access numpy array within PyCXX

Hi. I would like to convert numpy array to some double* or stl vector on the c++ side. I'm actually using PyCXX for this and I can't figure out the way to access the data. I'm currently able to access and return the data buffer like this : Py::Object arrayShape(const Py::Tuple& args ){ Py::Object array= args[0]; return arra...

Netbeans settings for PyQt4

I installed python-qt4 package (and other dependencies) and have netbeans with python support on ubuntu. What settings in netbeans must i change to be able to import from PyQt4? ...

Django Sphinx Text Search

I am trying out Sphinx search in my Django project. All setup done & it works but need some clarification from someone who has actually used this setup. In my Sphinx search while indexing, I have used 'name' as the field in my MySQL to be searchable & all other fields in sql_query to be as attributes (according to Sphinx lingo). So wh...

How to change file names using regular expressions in Python?

I have a directory which contains subdirectories which contain files. All the file names have a prefix which I want to eliminate. The prefix is not exactly the same among all the files, but I have a regular expression that represents exactly the language of these prefixes. I'm trying to write a script in Python to change the name of each...

Python - Convert CSV to DBF

Hello, I would like to convert a csv file to dbf using python (for use in geocoding which is why I need the dbf file) - I can easily do this in stat/transfer or other similar programs but I would like to do as part of my script rather than having to go to an outside program. There appears to be a lot of help questions/answers for conver...

Is there way to turn list of answers from script as yielded values?

I have long running program that I want to keep responsive. The algorithm is recursive, so sometimes even the sub-tasks in longer running calls can be longer than shorter whole runs. I have tried to make it to use yield but only ended up with list full of generators in various levels of recursive list structure (list also multilevel hier...

Start simple web server and launch browser simultaneously in Python

I want to start a simple web server locally, then launch a browser with an url just served. This is something that I'd like to write, from wsgiref.simple_server import make_server import webbrowser srv = make_server(...) srv.blocking = False srv.serve_forever() webbrowser.open_new_tab(...) try: srv.blocking = True except KeyboardInte...

Can I use Python to run html

hi there. i am writing an HTML editor and would like to make a section so that you can view how it would look in web browser directly in the program is this possible? Thanks so much ...

Python: how can i find minimum and maximum values in subarrays elements ?

hi, I've the following array: [[499, 3], [502, 3], [502, 353], [499, 353]] They are the verteces of a rectangle. I need to find the top-left, top-right, bottom-left and bottom-right vertex. What's the best python code to do it ? thanks ...

How do I check if a sentence contains a certain word in Python and then perform an action?

Let's say that I ask a user for raw input and they said, "This is a message." If that raw input contained the word "message" it would perform an action after that. Could I see how this can be done? ...

How would I save time with or statements in Python?

I'm writing a AI program in Python and want to save time when interacting with the bot. Instead of using this code: if "how are you" or "How are you" in talk: perform_action() I want to be able to interpret it even if it's not capitalize or not. If you don't what I'm saying let's say I asked the bot, "how are you?", but the bot w...

Python: how can I get rid of the second element of each sublist ?

I have a list of sublists, such as: [[501, 4], [501, 4], [501, 4], [501, 4]] How can I get rid of the second element for each sublist ? (i.e. 4) [501, 501, 501, 501] Should I iterate the list or is there a faster way ? thanks ...

file tree extended comparison

There has been a similar question concerning comparison of file trees, but it was suggested to start a new question. I think to write a file tree comparison tool for huge directory trees including extended attributes. The available tools like find, diff, xattr seem to be not optimum for that. I want to compare huge file trees incremen...