python

How do you compile wxPython under cygwin?

I am using CYGWIN as a platform and would like to use wxPython. Is there a way to get the source compiled and working in cygwin? ...

Adding a dimension to every element of a numpy.array

I'm trying to transform each element of a numpy array into an array itself (say, to interpret a greyscale image as a color image). In other words: >>> my_ar = numpy.array((0,5,10)) [0, 5, 10] >>> transformed = my_fun(my_ar) # In reality, my_fun() would do something more useful array([ [ 0, 0, 0], [ 5, 10, 15], [10,...

Python Input/Output, files

I need to write some methods for loading/saving some classes to and from a binary file. However I also want to be able to accept the binary data from other places, such as a binary string. In c++ I could do this by simply making my class methods use std::istream and std::ostream which could be a file, a stringstream, the console, whatev...

In Django, how does one filter a QuerySet with dynamic field lookups?

Given a class: from django.db import models class Person(models.Model): name = models.CharField(max_length=20) Is it possible (and if so how) to have a QuerySet that filters based on dynamic arguments, likeso: # instead of Person.objects.filter(name__startswith='B') # and Person.objects.filter(name__endswith='B') # is th...

Does anyone know of a python based web ui for snmp monitoring?

Comparable to cacti or mrtg. ...

Python library to modify MP3 audio without transcoding

I am looking for some general advice about the mp3 format before I start a small project to make sure I am not on a wild-goose chase. My understanding of the internals of the mp3 format is minimal. Ideally, I am looking for a library that would abstract those details away. I would prefer to use Python (but could be convinced otherwise)....

using rstrip on form.cleaned_data[i] in Django

In my views.py, i have a snippit of code like this: def clean_post_data(form): for i in form.cleaned_data: form.cleaned_data[i] = form.cleaned_data[i].rstrip() def add_product(request): form = ProductForm(request.POST, request.FILES or None) image = Image.objects.all() action = "Add" if request.POST: i...

Python GTK MVC

I've been looking around for a good MVC framework for Python using PyGTK. I've looked at Kiwi but found it a bit lacking, especially with using the Gazpacho Glade-replacement. Are there any other nice desktop Python MVC frameworks? I'm one of the few (it seems) to not want a webapp. ...

Any DAL/ORM on GAE?

Is there any Database Abstraction Layer (DAL) or Object Relational Mapper (ORM) that works on Google App Engine (GAE), and on normal relational databases (RDBS), other than web2py's? If not, is anybody working on porting one of the existing DAL/ORM to GAE? ...

Cleaning form data in Django

How can i clean and modify data from a form in django. I would like to define it on a per field basis for each model, much like using ModelForms. What I want to achieve is automatically remove leading and trailing spaces from defined fields, or turn a title (from one field) into a slug (which would be another field). ...

Modern, high performance bloom filter in Python?

I'm looking for a production quality bloom filter implementation in Python to handle fairly large numbers of items (say 100M to 1B items with 0.01% false positive rate). Pybloom is one option but it seems to be showing its age as it throws DeprecationWarning errors on Python 2.5 on a regular basis. Joe Gregorio also has an implementat...

How to indent Python list-comprehensions?

List comprehensions can be useful in certain situations, but they can also be rather horrible to read.. As a slightly exaggerated example, how would you indent the following? allUuids = [x.id for x in self.db.query(schema.allPostsUuid).execute(timeout = 20) if x.type == "post" and x.deleted is not False] ...

python as a "batch" script (i.e. run commands from python)

I'm working in a windows environment (my laptop!) and I need a couple of scripts that run other programs, pretty much like a windows batch file. how can I run a command from python such that the program when run, will replace the script? The program is interactive (for instance, unison) and keeps printing lines and asking for user input...

Accidental overwrite of OSX Python system framework

I got ahead of myself and downloaded and installed the OSX Python 2.6 package from www.python.org/download/ on my OSX 10.5.5 Intel Mac and installed the full package contents. Only after this did I come across http://wiki.python.org/moin/MacPython/Leopard stating that you should do a partial install of the package to avoid interfering wi...

How to print date in a regular format in Python ?

I'm only just starting out with python so I'm still pretty clueless. What I'm trying to do is to get the date from the pc and adding it to a list. This is my code: import datetime today = datetime.date.today() print today This prints: 2008-11-22 which is exactly what I want BUT....I have a list I'm appending this to and then suddenly ...

Public free web services for testing soap client

Are there any publicly available SOAP 1.2/WSDL 2.0 compliant free web services for testing a Python based soap client library (e.g. Zolera SOAP Infrastructure)? So far, it appears to me that Google Web API may be the only option. Otherwise, how can one test a SOAP 1.2 compliant client library? ...

Parsing GPS receiver output via regex in Python

I have a friend who is finishing up his masters degree in aerospace engineering. For his final project, he is on a small team tasked with writing a program for tracking weather balloons, rockets and satellites. The program receives input from a GPS device, does calculations with the data, and uses the results of those calculations to con...

Python - Create a list with initial capacity

Code like this often happens: l = [] while foo: #baz l.append(bar) #qux This is really slow if you're about to append thousands of elements to your list, as the list will have to constantly be re-initialized to grow. (I understand that lists aren't just wrappers around some array-type-thing, but something more complicated....

How do I convert Unicode to an integer value and not raise an exception if the text is not really an integer

I have some HTML I am trying to parse. There are cases where the html attributes alone are not going to help me identify the row type (header versus data). Fortunately, if my row is a data row then it should have some values that can be converted to integers. I have figured out how to convert the unicode to an integer for those cases ...

Good python library for designing a mmo? Actor based design

i m trying to design a mmo game using python... I have evaluated stackless and since it is not the general python and it is a fork, i dont want to use it I am trying to chose between pysage candygram dramatis and parley any one try any of these libraries? Thanks a lot for your responses ...