python

[pygtk] Change tab-label on gtk.noteBook

Hi to all. I have a gtk.Notebook with some tabs on it. How can i change label on current tab when button clicked? I make: self.set_tab_label(self.scrolled_window,label) But label change on last tab, but not in current :( Thank you. ...

python basic while loop

I have another newbie Python question. I have the following piece of code that I have a feeling is not written as pythonic as it should be: rowindex = 0 while params.getfirst('myfield'+rowindex): myid = params.getfirst('myfield'+rowindex) # do stuff with myid rowindex+=1 The input to this script is an ...

Assignment into Python 3.x Buffers with itemsize > 1

I am trying to expose a buffer of image pixel information (32 bit RGBA) through the Python 3.x buffer interface. After quite a bit of playing around, I was able to get this working like so: int Image_get_buffer(PyObject* self, Py_buffer* view, int flags) { int img_len; void* img_bytes; // Do my image fetch magic get_ima...

Django(postgresql) + lighttpd. Any issues with threading and python's postgresql driver?

I'd like to deploy my Django app (which uses postgresql as database) on lighttpd using FastCGI. For postgresql i see that Django has 2 backends available 'postgresql_psycopg2' and 'postgresql'. My question is that lighttpd being a threaded server are there any issues with any of this backends? Are they thread safe? And which one of them ...

Highlighting python stack traces

Hi all, I'm working on quite complex project and time after time I have to narrow down problems looking at stack traces. They happen to be very long and involve “my” code, standard library code and 3rd party libraries code at same time. Most of time the real problem is in “my” code and locating it instantly in a stack trace is a bit har...

tkinter: Specifying arguments for a function that's called when you press a button

button1 = tkinter.Button(frame, text="Say hi", command=print) button2 = tkinter.Button(frame, text="foo", command=print) button3 = tkinter.Button(frame, text="bar", command=print) You've probably spotted the hole in my program: print can't specify arguments. This renders the whole thing useless and faulty. Obviously, having something l...

HTTP Base SQLAlchemy database

Hi all. I have a little problem, I want to use SQLAlchemy (Elixr to be exact) to do some task on a RDBMS MySql on a web server I have in hosting. My Hosting provider does not allowe me to connect to MySql directly, just by php scripts... I was think to use a simple php script to tunnel the queies done by SQLAlchemy. There is some way to...

Do simple things with a Google Wave robot...

I wanted to add 3 features to the robot from the tutorial here: http://code.google.com/apis/wave/extensions/robots/python-tutorial.html Before adding all these features, my robot is working as intended. Now the odd features still shows up (with "v2" at the bck of the blip content), but neither of the new features shows up! I tried diffe...

Adding buildout eggs to virtualenv

I have a virtualenv, isolated (no-site-packages) from system site-packages. I have a buildout project with following cfg: [buildout] parts = develop = . eggs = myproject #no effect for now The myproject code for is here: buildout_top_folder/src/myproject/ I am carrying out activities inside the virtualenv. To make myprojec...

Searching a website

import urllib import re import os search = (raw_input('[!]Search: ')) site = "http://www.exploit-db.com/list.php?description="+search+"&author=&platform=&type=&port=&osvdb=&cve=" print site source = urllib.urlopen(site).read() founds = re.findall("href='/exploits/\d+",source) print "\n[+]Search",len(founds),"Re...

Python using derived class's method in parent class?

Can I force a parent class to call a derived class's version of a function? class Base(object): attr1 = '' attr2 = '' def virtual(self): pass # doesn't do anything in the parent class def func(self): print "%s, %s" % (self.attr1, self.attr2) self.virtual() and a class that derive...

Scripting language for trading strategy development

I'm currently working on a component of a trading product that will allow a quant or strategy developer to write their own custom strategies. I obviously can't have them write these strategies in natively compiled languages (or even a language that compiles to a bytecode to run on a vm) since their dev/test cycles have to be on the orde...

Creating a custom sys.stdout class?

What I'm trying to do is simply have the output of some terminal commands print out to a wx.TextCtrl widget. I figured the easiest way to accomplish this is to create a custom stdout class and overload the write function to that of the widget. stdout class: class StdOut(sys.stdout): def __init__(self,txtctrl): sys.stdout._...

Python's standard library - is there a module for balanced binary tree?

Is there a module for AVL or Red-Black or some other type of a balanced binary tree in the standard library of Python? I have tried to find one, but unsuccessfully (I'm relatively new to Python). ...

Local App Engine datastore is slow once loaded up, any suggestions?

I've loaded up a local datastore with 40,000+ entries. Unfortunately, recalling any data from it at all is very slow on my fairly new Macbook Pro. Any suggestions on speeding things up, short of buying a new piece of hardware? ...

warnings emitted during 'easy_install'

When I easy_install some python modules, warnings such as: <some module>: module references __file__ <some module>: module references __path__ <some module>: module MAY be using inspect.trace <some module>: module MAY be using inspect.getsourcefile sometimes get emitted. Where (what package / source file) do these messages come from...

Are any of these quad-tree libraries any good?

It appears that a certain project of mine will require the use of quad-trees, something that I have never worked with before. From what I have read they should allow substantial performance enhancements than a brute-force attempt at the problem would yield. Are any of these python modules any good? Quadtree 0.1.2 <= No: unable to execu...

Most optimal way to programmatically check if site is running locally or on a server with Django?

Currently I have this in my settings.py file: DEBUG = True LOCAL = True TEMPLATE_DEBUG = DEBUG SITE_TITLE = 'Stack Overflow Question' REMOTE_SITE_URL = "http://************:8080" LOCAL_SITE_URL = "http://************:8000" ADMINS = ( # ('Your Name', '[email protected]'), ) MANAGERS = ADMINS if LOCAL: SITE_URL = LOCAL...

Is nested dictionary in design ok?

My data is structured in a way that I ended up creating a nested dictionary in my design like: my_dict = {"a": {"b": {"c":"I am c"}}} my_dict["a"]["b"]["c"] Is it usual! or we have some other better alternatives (using objects!)? ...

How do I use Flickzeug to get interactive tracebacks from a paste deploy WSGI pipeline?

I'd like to use Flickzeug to see interactive tracebacks by adding it to my paste deploy file's pipeline. The following doesn't work. What will? [pipeline] pipeline = flickzeug myapp ...