python

Best python UI package for simple graph simulations (TSP simulation, etc...)

I've never done any UI programming in python before. What is the best (read most intuitive, easy to use, functional) UI package for python for doing simulations? I'll be doing a simulation of TSP right now. So I'll have a graph (nodes and edges) where the edges are rapidly changing, along with some selection boxes to choose differen...

How to create folders using file names and then move files into folders?

I have hundreds of text files in a folder named using this kind of naming convention: Bandname1 - song1.txt Bandname1 - song2.txt Bandname2 - song1.txt Bandname2 - song2.txt Bandname2 - song3.txt Bandname3 - song1.txt ..etc. I would like to create folders for different bands and move according text files into these folders. How could ...

Why is my simple python gtk+cairo program running so slowly/stutteringly?

My program draws circles moving on the window. I think I must be missing some basic gtk/cairo concept because it seems to be running too slowly/stutteringly for what I am doing. Any ideas? Thanks for any help! #!/usr/bin/python import gtk import gtk.gdk as gdk import math import random import gobject # The number of circles and the w...

Where can i get OpenCV for python?

Where can i get OpenCV for python?What are the pre-requisites?? i tried to install opencv-python through synaptic package manager but Python says No module named CVtypes ...

Python: automated change in variable contents

Hi, I have a Python function which receives numerous variables, and builds an SQL query out of them: def myfunc(name=None, abbr=None, grade=None, ...) These values should build an SQL query. For that purpose, Those who equal None should be changed to NULL, and those who store useful values should be embraced with 's: name="'"+name+"...

How to do a JOIN in SQLAlchemy on 3 tables, where one of them is mapping between other two?

Suppose I have the following tables: Articles with fields article_id, title Tags with fields tag_id, name ArticleTags with fields article_id, tag_id And I wish to find all articles that have a given tag. How do I create this complicated join in SQLAlchemy? In SQL it would look like: SELECT a.article_id, a.title FROM Articles AS a J...

How to create nested lists in python?

I know you can create easily nested lists in python like this: [[1,2],[3,4]] But how to create a 3x3x3 matrix of zeroes? [[[0] * 3 for i in range(0, 3)] for j in range (0,3)] or [[[0]*3]*3]*3 Doesn't seem right. There is no way to create it just passing a list of dimensions to a method? Ex: CreateArray([3,3,3]) ...

How can I draw nodes and edges in PyQT?

In PyQT, how can I plot small "Nodes" at given points and connect them with edges? All of the PyQT tutorials I find are "plot a button! plot a checkbox!" Huge thanks in advance ...

Is there any way to create a class property in Python?

The following doesn't work for some reason: >>> class foo(object): ... @property ... @classmethod ... def bar(cls): ... return "asdf" ... >>> foo.bar <property object at 0x1da8d0> >>> foo.bar + '\n' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) fo...

Python Iteration Problem!!

I have this code here, it is supposed to remove the common letters from both the lists n1 and n2. But when i run this code it only runs once as in it removes only 'a' from both n1 and n2 and doesnt remove 'k'. Just to clarify this code should always work on only 2 words. name1 = "abdjek" name2 = "doarhsnk" n1l = list(name1) n2l = list...

In Python, what is a preferred naming convention for the backing store of an internal property?

Say you have a public method in Python whose primary purpose is to retrieve the value of an underlying data attribute (i.e. internal backing store). The method may have lazy evaluation logic, etc. A property is an example of such a method. Then it is natural to use the same name for the method and data attribute, except for an underscor...

two conflicting meanings of builtins in python 3 (python 3.1, python 3k, python3000)

i just posted below query to comp.lang.python, but i feel this kind of question has some kind of right-of-way here on stackoverflow, too, so be it repeated. the essence: why does ‘builtins’ have two distinct interpretations in python 3?—here the details go: i would be very gladly accept any commentaries about what this sentence, gleaned...

In PyQt, how can signals and slots be used to connect a dropdownlist to a function?

In PyQt, there's a concept of signals and slots to connect objects to one another's functions, but I can't seem to find them referenced to functions not associated with other objects. For example, I want a dropdown list to have algorithm A or algorithm B run. How does PyQt accomplish this functionality? ...

Returning binomal as a tuple

I want to save the results of my function binomal_aux to a tuple but I don't have an idea how to, here is my code I have right now. def binomal (n): i=0 for i in range(n): binomal_aux(n,i) #want this to be in a tuple so, binomal (2) = (1,2,1) return def binomal_aux (n,k): if (k==0): return 1 elif...

Python lib for generating 3d charts?

Is there any charting lib for python that can generate 3d charts like this one? ...

How do I encode WSGI output in UTF-8?

I want to send an HTML page to the web browser encoded as UTF-8. However the following example fails: from wsgiref.simple_server import make_server def app(environ, start_response): output = "<html><body><p>Räksmörgås</p></body></html>".encode('utf-8') start_response('200 OK', [ ('Content-Type', 'text/html'), ('...

python chaco axis labels time formatting

In Enthought's Chaco, the TimeFormatter class is used to format the time string of the tick labels. is there a way to specify the time format (something like time.strftime()). the source code now hard-codes the format when displaying month and day of the month to the american style (MMDD). I would like to add some flexibility so that ...

how to sort 2d array by row in python?

i have 2d array,dimension 3x10,and i want to sort by values in 2nd row,from lowest to highest value,any useful tip? ...

Can't get wx.BufferedDC to draw anything.

I've got a problem with DCs. I'm trying to make an application that will draw many lines on the screens and needs to update really fast, and since I don't want flickering, I decided to give buffered dcs a shot. But when I run this code, it doesn't draw anything. What am I doing wrong? import wx class MainFrame(wx.Frame): def __init...

pinax ImportError cannot import name UserOpenidAssociation

i have these errors ImportError at / cannot import name UserOpenidAssociation i could make any sense out of the traceback equest Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.1.1 Python Version: 2.6.1 Installed Applications: ['inventory.inlanddbase'] Installed Middleware: ('django.middleware.common.CommonMiddleware'...