python

python IPC (Inter Process Communication) for Vista UAC (User Access Control)

I am writing a Filemanager in (wx)python - a lot already works. When copying files there is already a progress dialog, overwrite handling etc. Now in Vista when the user wants to copy a file to certain directories (eg %Program Files%) the application/script needs elevation, which cannot be asked for at runtime. So i have to start anothe...

Django: QuerySet order by method

Hi! Let's say I have the following model: class Contest: title = models.CharField( max_length = 200 ) description = models.TextField() class Image: title = models.CharField( max_length = 200 ) description = models.TextField() contest = models.ForeignKey( Contest ) user = models.ForeignKey( User ) def score...

The OLE way of doing drag&drop in wxPython

I have wxPython app which is running on MS Windows and I'd like it to support drag&drop between its instances (so the user opens my app 3 times and drags data from one instance to another). The simple drag&drop in wxPython works that way: User initiates drag: The source window packs necessary data in wx.DataObject(), creates new wx.Dr...

Where can i get a wiki formatting widget for my django application?

Am looking for a wiki formatting widget for my django application, just like the one am using to type this question in stackoverflow? ...

Detect duplicate MP3 files with different bitrates and/or different ID3 tags?

How could I detect (preferably with Python) duplicate MP3 files that can be encoded with different bitrates (but they are the same song) and ID3 tags that can be incorrect? I know I can do an MD5 checksum of the files content but that won't work for different bitrates. And I don't know if ID3 tags have influence in generating the MD5 ch...

Python as your main language. Possible?

I am currently attending college and the languages that I will 'know' by graduation are C++ and Java. That being said, i am also in the process of teaching myself Python. I know that every programming language has its own pros and cons, but would it be possible to become a python developer out of school? I always have more 'fun' programm...

Trimming Mako output

I really like the Mako templating system that's used in Pylons and a couple other Python frameworks, and my only complaint is how much WS leaks through even a simple inheritance scheme. Is there anyway to accomplish below, without creating such huge WS gaps... or packing my code in like I started to do with base.mako? Otherwise to get ...

Is there a way to install the scipy special module without the rest of scipy?

I'm writing some Python numerical code and would like to use some functions from the special module. So far, my code only depends on numpy, which I've found very easy to install in a variety of Python environments. Installing scipy, on the other hand, has generally been an exercise in frustration. Is there a way to get just the special ...

Django "Did you mean?" query

Hi all, I am writing a fairly simple Django application where users can enter string queries. The application will the search through the database for this string. Entry.objects.filter(headline__contains=query) This query is pretty strait forward but not really helpful to someone who isn't 100% sure what they are looking for. So I ex...

Python Regular Expression to add links to urls

I'm trying to make a regular expression that will correctly capture URLs, including ones that are wrapped in parenthesis as in (http://example.com) and spoken about on coding horror at http://www.codinghorror.com/blog/archives/001181.html I'm currently using the following to create HTML A tags in python for links that start with http an...

Resolving a relative url path to it's absolute path

Is there a library in python that works like this? >>> resolvePath("http://www.asite.com/folder/currentpage.html", "anotherpage.html") 'http://www.asite.com/folder/anotherpage.html' >>> resolvePath("http://www.asite.com/folder/currentpage.html", "folder2/anotherpage.html") 'http://www.asite.com/folder/folder2/anotherpage.html' >>> resol...

Is anyone using meta-meta-classes / meta-meta-meta-classes in Python/ other languages?

I recently discovered metaclasses in python. Basically a metaclass in python is a class that creates a class. There are many useful reasons why you would want to do this - any kind of class initialisation for example. Registering classes on factories, complex validation of attributes, altering how inheritance works, etc. All of this be...

Cygwin and Python 2.6

New to python (and programming). What exactly do I need from Cygwin? I'm running python 2.6 on winxp. Can I safely download the complete Cygwin? It just seems like a huge bundle of stuff. ...

Resources for TDD aimed at Python Web Development

I am a hacker not and not a full-time programmer but am looking to start my own full application development experiment. I apologize if I am missing something easy here. I am looking for recommendations for books, articles, sites, etc for learning more about test driven development specifically compatible with or aimed at Python web appl...

Get foreign key without requesting the whole object

Hi, I have a model Foo which have a ForeignKey to the User model. Later, I need to grab all the User's id and put then on a list foos = Foo.objects.filter(...) l = [ f.user.id for f in foos ] But when I do that, django grabs the whole User instance from the DB instead of giving me just the numeric user's id, which exist in each Foo...

python string join performance

There are a lot of articles around the web concerning python performance, the first thing you read: concatenating strings should not be done using '+': avoid s1+s2+s3, instead use str.join I tried the following: concatenating two strings as part of a directory path: three approaches: '+' which i should not do str.join os.path.join H...

Splitting a large XML file in Python

I'm looking to split a huge XML file into smaller bits. I'd like to scan through the file looking for a specific tag, then grab all info between and , then save that into a file, then continue on through the rest of the file. My issue is trying to find a clean way to note the start and end of the tags, so that I can grab the text insid...

Using a java library from python.

I have a python app and java app. The python app generates input for the java app and invokes it on the command line. I'm sure there must be a more elegant solution to this; just like using JNI to invoke C code from Java. Any pointers? (FYI I'm v. new to Python) Clarification (at the cost of a long question: apologies) The py app (w...

How to read Unicode input and compare Unicode strings in Python ?

I work in Python and would like to read user input (from command line) in Unicode format, ie a Unicode equivalent of raw_input ? Also, I would like to test Unicode strings for equality and it looks like a standard == does not work ? Thank you for your help ! ...

python import coding style

I've discovered a new pattern. I wonder if anyone else has this pattern or has any opinion about it. Basically, I have a hard time scrubbing up and down source files to figure out what module imports are available and so forth, so now, instead of import foo from bar.baz import quux def myFunction(): foo.this.that(quux) I move a...