python

OpenGL frame buffer slow and spontaneously stalls. Can even cause a system crash when used extensively.

Apparently frame buffers are fast and the best way to render offscreen to textures or to simply pre-create things. My game however is not liking them at all. In the current code frame buffers are used often, sometimes each frame, several times. When used the game begins to slow down but not instantly. It seems to take time (Perhaps a bu...

Polymorphism - adding to existing methods while overwriting them

I want to be able to subclass a class, and define __init__ but still run the old __init__ as well. To illustrate, say I have the following classes: class A(object): def __init__(self): self.var1 = 1 class B(A): def __init__(self) self.var2 = 2 doInitForA() And I want to be able to do this: instB = B(...

Using code generated by Py++ as a Python extension

I have a need to wrap an existing C++ library for use in Python. After reading through this answer on choosing an appropriate method to wrap C++ for use in Python, I decided to go with Py++. I walked through the tutorial for Py++, using the tutorial files, and I got the expected output in generated.cpp, but I haven't figured out what to...

Python2.6 and Snow Leopard. Problem installing appscript (and MANY other packages)

I've been having nothing but trouble with python2.6 and Snow Leopard. One major problem is 32 vs 64-bit libraries. The other manifests itself like this: tppllc-mbp15$ sudo easy_install-2.6 appscript Searching for appscript Reading http://pypi.python.org/simple/appscript/ Reading http://appscript.sourceforge.net Best match: appscript 0....

Getting Django comments to be able to use bold and italic style

So I'm trying to get rich text to work for the cheeserater program where I added a commenting system using the tinyMCE editor in the textarea. This is what it looks like: <table><td align=left> {% get_comment_list for package as comment_list %} {% for comment in comment_list %} {{ comment.comment|safe }}<br> {% endfor %} </table> ...

recv-q and send-q between spawning+memcached gets bloated after a few hours

I'm using python-memcached 1.45 with python 2.5.2, django 1.0.4, spawning 0.9.2, eventlet 0.9.3 and libevent 1.3 on 64bit debian lenny. spawning server is started with parameters given below: /usr/bin/python /usr/bin/spawn --factory=spawning.django_factory.config_factory myproject.settings \ --port=8006 --processes=1 --threads=0 --st...

Django - Iterate over model instance field names and values in template

I'm trying to create a basic template to display the selected instance's field values, along with their names. Think of it as just a standard output of the values of that instance in table format, with the field name (verbose_name specifically if specified on the field) in the first column and the value of that field in the second colum...

Can existing virtualenv be upgraded gracefully?

I have a virtualenv created for Python 2.5 and want to "upgrade" it to Python 2.6. Here is how it was originally set up: virtualenv --no-site-packages -p python2.5 myenv I now run virtualenv in the same directory to upgrade: virtualenv --no-site-packages -p python2.6 myenv ... Not overwriting existing python script myenv/bin/pyth...

Django and NoneType object is not callable

I have such model: class Body(models.Model): point = models.TextField() description = models.TextField(blank = True) order = models.IntegerField(default = 0, blank = True) When I am adding in django admin interface a new record I am getting 'NoneType' object is not callable with TemplateSyntaxError message. So, record i...

wx 'easy gui' library; how do I keep this code from crashing IDLE & Other python IDEs?

When I run this code in IDLE, it crashes. However, if I run it outside of IDLE it works just fine. There are a couple of Python IDEs that are written in python that suffer the same problem, but if I use an IDE/editor that's not based on it, those run fine as well. Is there any way of modifying this code so it doesn't muck up IDLE & Fr...

Using Python Reg Exp to read data from file

I'm having trouble using python reg exp to read data from a file. The file has data I want and some info I'm not interested in. An example of the info I'm interested in is below. The number of rows will vary FREQ VM(VOUT) 1.000E+00 4.760E+01 1.002E+00 4.749E+01 Y I want to create a list of tuples like: [(1.000, 47.6),(...

access ElementTree node parent node

I am using the builtin Python ElementTree module. It is straightforward to access children, but what about parent nor sibling nodes? - can this be done efficiently without traversing the entire tree? ...

Using a python module's C API in my own C module

Hello. This seems to be sort of what I want, except I want to make an instance of a C PyObject in another C module. http://stackoverflow.com/questions/1147452/create-instance-of-a-python-class-declared-in-python-with-c-api But I am not able to find the documentation for using a Python module from C. I can't seem to find the relevent d...

Why (dictionary.keys()).sort() is not working in python ?

Hi, I'm new to Python and can't understand why a thing like this does not work. I can't find the issue raised elsewhere either. toto = {'a':1, 'c':2 , 'b':3} toto.keys().sort() #does not work (yields none) (toto.keys()).sort() #does not work (yields none) eval('toto.keys()').sort() #does not work (yields none) Yet...

Python __init__ argument problem

I have some trouble understanding what happens with class init arguments that are lists like: class A(object): def __init__(self, argument=[]): self.argument = argument[:] or: def __init__(self,argument=None): self.arguments = arguments or [] or: def __init__(self, argument=[]): self.argument = argume...

how to wait for a pause in user input in a gtk.TextBuffer?

I'm trying to write a simple gui-based application in pygtk which provides 'live' previewing of text-based markup. The markup processing, however, can be quite computationally expensive and slow to run, so updating the preview on every keystroke is not really viable. Instead I'd like to have the update run only when user input lapses. ...

Get first list index containing sub string in Python

For lists the method list.index(x) returns the index in the list of the first item whose value is x. But if I want to look inside the items, and not just at the whole items, how do I make the slickest Python method for this? For example, with l = ['the cat ate the mouse','the tiger ate the chicken','the horse ate the straw'] this fun...

Trouble with MySQL UPDATE syntax with the module mysqldb in Python

I am attempting to execute the following query via the mysqldb module in python: for i in self.p.parameter_type: cursor.execute("""UPDATE parameters SET %s = %s WHERE parameter_set_name = %s""" % (i, float(getattr(self.p, i)), self.list_box_parameter.GetStringSelection())) I keep getting the error: "Unknown column 'M...

no module names _mysql; where is _mysql

import MySQLdb and traceback: Traceback (most recent call last): File "D:\zjm_code\sphinx_test\a.py", line 1, in <module> import MySQLdb File "D:\zjm_code\sphinx_test\MySQLdb\__init__.py", line 19, in <module> import _mysql ImportError: No module named _mysql ...

Python - Display string containing entity references as normal text

I have a Python string "&#039;&#039;Grassmere&#039;&#039;" as retrieved from a website. I would like to have the &#039; displayed as the correct ascii symbol (') but for some reason python insists on just printing the ascii code. ...