python

'proper' & reliable way to get all installed windows programs in Python?

I've seen numerous ways of retrieving installed programs on WinXP+ in python. What is the proper and most robust way of doing this? Currently I'm accessing HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall and reading each of the keys from there to get a list. (I've been told this isn't the proper way of doing things) I've...

New field in Django model doesn't show up in admin interface or model forms

I've created a model in one of my apps which works fine. However, I needed to add a new field. I did this, and used manage.py reset <appname> to drop the tables and add them again. This process went fine - the new field appears in the database. However, I can't get the field to show up in the admin interface, nor in the custom model form...

Python/Django shell won't start

One of the great features of Django is that you can open a python interpreter set-up for use with your project. This can be used to analyse objects in a database and allows any python commands to be executed on your project. I find it essential for Django development. It is invoked in the project directory using this command: $ python m...

static file with mod_wsgi in django

Hello, I've searched a lot but I still have a problem with the static files (css, image,...) with my django website. I'm using mod_wsgi with apache on archlinux 64bits I've added it in my http.conf : LoadModule wsgi_module modules/mod_wsgi.so <VirtualHost *:80> WSGIDaemonProcess mart.localhost user=mart group=users processes=2 ...

Custom Django admin widgets for many-to-many relations

Let's say I have the following Django models with these ForeignKey fields (simplified syntax): class Container(Model): items -> Item sub_items -> SubItem sub_sub_items -> SubSubItem class Item(Model): container -> Container children -> SubItem class SubItem(Model): container -> Container parent -> Item ...

Python class that inherits from itself? How does this work?

Relatively new to Python, and I saw the following construct in the PyFacebook library (source here: http://github.com/sciyoshi/pyfacebook/blob/master/facebook/init.py#L660). I'm curious what this does because it appears to be a class that inherits from itself. class AuthProxy(AuthProxy): """Special proxy for facebook.auth.""" ...

generating a binary tree from given data in python

i wanted to know how to read values from a list into a binary tree. i have a triangle like this: 0 1 2 3 4 5 6 7 8 9 i have written a class node like this class node: def __init__(self,data,left=None,right=None): self.data=data self.left=left self.right=right basically...

GAE Simple Searching + Autocomplete

I'm looking to create a search function for my flash game website. One of the problems with the site is that it is difficult to find a specific game you want, as users must go to the alphabetical list to find one they want. It's run with Google App Engine written in python, using the webapp framework. At the very least I need a simple...

Passing options to Python executable in non-interactive mode

I would like to pass some options to Python (version 2.6) every time, not just in interactive mode. Is there a file I can put such commands in? EDIT: Specifically, I'm wanting to silence the Deprecation warnings. ...

Pythonic way to sort list of objects by a dict value (by key) contained within the object

I'm seeking advice on doing the following in a more pythonic way. Consider: class MyObj(object): def __init__(self): self.dict_properties = {} Suppose I've got a list which contains multiple MyObj instances: mylist = [<__main__.MyObj object at 0x1005e3b90, ...] Now i want to sort mylist based on the value of a certain ...

How to get the EXIF or meta-data from images?

I need a really good library or a command-line software that can be used to extract Exif data from images. No specific programming language, except the library or the software has to work really well. I found various libraries for PHP and Python, but most of it hasn't been updated or being maintained and don't work for various manufact...

wx.Font uses a facename & PIL.ImageFont uses a filename... Is there any way to relate the two??

Hey guys, sorry but this is going to be a big one.. ;) I'm running into an annoying little snag right now. I'm creating an RSS-style app for work which will be placed on some large LCD displays across the office. The basic concept is to have a client/server setup where the user would use a custom editor to create the individual articles...

New to OpenGL and deprecation.

Hello, I've begun playing around with OpenGL in Python using PyOpenGL 3.0.1b. I looked at some sample code and started running it and modifying it etc. All was well until I became a little less ignorant. On http://pyopengl.sourceforge.net/documentation/manual-3.0/index.xhtml the OpenGL functions are listed as well as whether or not th...

Better way to port Java into Python? (Hello World Servlet)

After several hours of working on porting this program over, it appears to finally be in a working state. However, I was wondering if anyone knew of a better way or more complete way of porting Java servlets over into Python. The beginning of the Python script contains a lot of support code to make it easier to port the program line-by-l...

Which methods implement the buffer interface in Python?

I have a custom class with a serialize method, and I want to be able to write this class directly to files and have the return value of the serialize method get written, in Python 2.6. (I'm not trying to pickle my objects, this is something totally different.) For example: class Foo(object): def serialize(self): return "Hel...

Missing datetime.time.__sub__?

Why I can't subtract two time object? 12:00 - 11:00 = 1:00 from datetime import time time(12,00) - time(11,00) # -> timedelta(hours=1) Actually TypeError: unsupported operand type(s) for -: 'datetime.time' and 'datetime.time' ...

How to copy a file via the browser to Amazon S3 using Python (and boto)?

Creating a file (key) into Amazon S3 using Python (and boto) is not a problem. With this code, I can connect to a bucket and create a key with a specific content: bucket_instance = connection.get_bucket('bucketname') key = bucket_instance.new_key('testfile.txt') key.set_contents_from_string('Content for File') I want to upload a file ...

String matching in Python

does anyone know which string matching algorithm is implemented in Python? ...

Data modeling advice for a forum application on Google App Engine

I'm writing a simple forum-like application on Google App Engine and trying to avoid scalability issues. I'm new to this non-RBDMS approach, i'd like to avoid pitfalls from the beginning. The forum design is pretty simple, posts and replies will be the only concepts. What will be the best approach to the problem if the forum have million...

What happen when I add a Django app to INSTALLED_APPS?

Here is the situation. I have a django project with two installed apps. Both apps appear to function properly if they are installed independently of each other. However if I list both apps in the settings.INSTALLED_APPS the reverse() function seems to break for urls in the first app. So this leads me to believe that a bug in the seco...