python

NLTK - how to find out what corpora are installed from within python?

I'm trying to load some corpora I installed with the NLTK installer but I got a: >>> from nltk.corpus import machado Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name machado But in the download manager (nltk.download()) the package machado is marked as installed a...

Is Google App Engine right for me?

Hi, I am thinking about using Google App Engine.It is going to be a huge website. In that case, what is your piece of advice using Google App Engine. I heard GAE has restrictions like we cannot store images or files more than 1MB limit(they are going to change this from what I read in the GAE roadmap),query is limited to 1000 results,...

Validate that atleast one modelfield has value in Django admin

Given the following model, how do I require that atleast one of the two fields has been given a value? class ZipUpload(models.Model): zip_file = models.FileField(upload_to="/tmp", blank=True, help_text='Select a file to upload.') zip_file_path = models.FilePathField(path="/tmp", blank=True, ...

Are there any matrix math modules compatible with Python 3.x?

When I began this project, I thought it would be easy to get libraries for common stuff like matrix math, so I chose to work in Python 3.1- it being the most recent, updated version of the language. Unfortunately, NumPy is only compatible with 2.5 and 2.6 and seems to be the only game in town! Even other stuff that I turned up like gam...

Python image writer 3.*

Im looking for a library/snippet to write image files (bmp) to disk. PIL site says it doesnt work for 3.1 At the moment im writing a html file which uses javascript canvas to display result... ...

How can I "zip sort" parallel numpy arrays?

If I have two parallel lists and want to sort them by the order of the elements in the first, it's very easy: >>> a = [2, 3, 1] >>> b = [4, 6, 2] >>> a, b = zip(*sorted(zip(a,b))) >>> print a (1, 2, 3) >>> print b (2, 4, 6) How can I do the same using numpy arrays without unpacking them into conventional Python lists? ...

libnet creates UDP packets with invalid checksums

I'm using pylibnet to construct and send UDP packets. The UDP packets I construct in this way all seem to have invalid checksums. Example: # python Python 2.4.3 (#1, Sep 3 2009, 15:37:12) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import libnet >>>...

How can I deal with python eggs for multiple platforms in one location?

We have a common python installation for all of our systems in order to ensure every system has the same python installation and to ease configuration issues. This installation is located on a shared drive. We also have multiple platforms that share this installation. We get around conflicting platform-specific files by setting the --...

How to get progress of file move in python?

I've got a little script for sorting out my dowloaded files and it works great, but I'd like to print out the progress of a file move, for when it's doing the big ones, right now I do something like: print "moving..." os.renames(pathTofile, newName) print "done" But I'd like to be able to see something like a progress bar ( [..... ...

Getting a list of all churches in a certain state using Python.

Hi, I am pretty good with Python, so pseudo-code will suffice when details are trivial. Please get me started on the task - how do go about crawling the net for the snail mail addresses of churches in my state. Once I have a one liner such as "123 Old West Road #3 Old Lyme City MD 01234", I can probably parse it into City, State, Street,...

why list comprehension is called so in python?

No flaming please, asking as a community wiki so nobody gets reputation here. I know python is not the first language to have list comprehension. I'm just interest in the history of the name. I'm particularly interested in why it's called comprehension ...

Django + MySQL on Mac OS 10.6.2 Snow Leopard

There were some excellent answers to this question already, however, they are now outdated. I've been able to get the module installed, but "python manage.py runserver" fails with iMac:myproject drhoden$ python manage.py runserver Validating models... Unhandled exception in thread started by <function inner_run at 0x10496f0> Traceb...

python libraries for programatic email access: mime, smpt, pop3

does python have built in libraries for accessing email? smtp, pop3, mime parsers etc? (coming from .net where these libraries are usually from 3rd party commercial companies) ...

Python: Checking Header Format

I'm new to python and need help with a problem. Basically I need to open a file and read it which I can do no problem. The problem arises at line 0, where I need to check the header format. The header needs to be in the format: p wncf nvar nclauses hard where 'nvar' 'nclauses' and 'hard' are all positive integers. For example: p wncf ...

Does Reddit use any type of ORM?

Sorry I want to learn Python, and was curious if Reddit's codebase uses any sort of ORM? ...

Run a remote python script from ASP.Net

I have a python script on a linux server that I can SSH into and I want to run the script on the linux server( and pass it parameters entered by the user) and get the output on an ASP.net webpage running on IIS. How would I be able to do that? Would it be easier if I was running a wamp server? Edit: The servers are in the same interna...

Python Observer Pattern: Examples, Tips?

Are there any exemplary examples of the GoF Observer implemented in Python? I have a bit code which currently has bits of debugging code laced through the key class (currently generating messages to stderr if a magic env is set). Additionally, the class has an interface for incrementally return results as well as storing them (in memory...

Python: Selecting to read the first line only

After reading in a file how would tell python to read the first line only? ...

Best dynamic languages for OpenGL/general graphics

Which are the most mature and well supported solutions for writing graphical programs? I have been using C++ with OpenGL/GLUT, but would like to try a more flexible and expressive approach. Ruby and Processing? Python and OGRE? What things have worked well for you? ...

PyQt: Call a TrayMinimized application.

I have an application wich is minimized to the tray (showing an icon) when the user close it. What I need to know is how can I call it back with a combination of keys, like Ctrl+Alt+Something. Actually I call it back when I double-click it, but it will be nice to do the same on a keystroke. Here is a portion of the code: # -*- coding: u...