python

MySQL to AppEngine

Hi Nick! How are you? I'm from Brazil and study at FATEC (college located in Brazil). I'm trying to learn about AppEngine. Now, I'm trying to load a large database from MySQL to AppEngine to perform some queries, but I don't know how i can do it. I did some testing with CSV files,but is there any way to perform the direct import from My...

How to get REALLY fast python over a simple loop

Edit2: I finally got it to pass at 10.54 seconds. I used nearly all of your answers to get there and thus it was hard to choose one as 'correct' but I believe the one I chose sums it up the best. Thanks to you all. Final passing code is below. Edit: I included some of the suggested updates in the included code. I'm working on a spo...

Ever used Pyro? (Python Robotics)

I was just reading up on a robotics-oriented implementation for Python called Pyro. It stopped production in 2005, but I wonder if anyone knows if its usable in 2.6, and how it compares to other languages' robotics. ...

Py GTK Drawing area and Rich Text Editor

I would like to include a rich text editor in a pygtk drawing area for an application i am developing. The editor ( a small resizable widget ) should be able to move around the drawing area like a rectangle. I am not sure how to start as I am pretty new to PyGTK. thank you ! ...

How to give an error when no options are given with optparse

I'm try to work out how to use optparse, but I've come to a problem. My script (represented by this simplified example) takes a file, and does different things to it depending on options that are parsed to it. If no options are parsed nothing is done. It makes sense to me that because of this, an error should be given if no options are...

How do I redirect stdin/stdout when I have a sequence of commands in Bash?

I've currently got a Bash command being executed (via Python's subprocess.Popen) which is reading from stdin, doing something and outputing to stdout. Something along the lines of: pid = subprocess.Popen( ["-c", "cmd1 | cmd2"], stdin = subprocess.PIPE, stdout = subprocess.PIPE, ...

Basic anydbm example generates 'AttributeError: iteritems'

I'm attempting a pretty cut & dry example of anydbm: #!/usr/bin/python import anydbm # Open database, creating it if necessary. db = anydbm.open('cache', 'c') # Record some values ...

How to run a django on .Net?

Possible Duplicate: Django on IronPython Is there any demo of the django on .net ? how should i build it in the .net environment? I am chinese ,and it is hard to search in chinese about that.... ...

Django database caching

I have a Django form that uses an integer field to lookup a model object by its primary key. The form has a save() method that uses the model object referred to by the integer field. The model's manager's get() method is called twice, once in the clean method and once in the save() method: class MyForm(forms.Form): id_a = fields.I...

How can I start using twill?

I am sorry I have already asked this question on "Superuser", but nobody answers there, so I deleted it from "Superuser" and decided to post it here. Hope it's not a big crime, especially given the fact that I was firstly advised to use twill here on "StackOverflow" (not on "SuperUser") How do I start using twill? I have just downloade...

how to call a c++ file from python without using any of the spam bindings?

i have this encryption algorithm written in C++ , but the values that has to be encrypted are being taken input and stored in a file by a python program . Thus how can i call this c++ program from python? ...

connecting Mud.............

hi, ive recently create a short and simple multi user dungeon, the things ive made is the engine of the game and the actually mud itself so when i click on the file it you can play the mud. the problem ive got is i dont know how to connect it so that more than one player can play. do you connect it to a server or something. i dont know ...

Embed bash in python

Hi, I am writting a python script and I am running out of time. I need to so some things that I know pretty well in bash, so I just wonder how can I embed some bash lines into a python script. Thanks ...

What is the advantage of using Python Virtualbox API?

what is the advantage of using a python virtualbox API instead of using XPCOM? ...

How to detect a sign change for elements in a numpy array

I have a numpy array with positive and negative values in. a = array([1,1,-1,-2,-3,4,5]) I want to create another array which contains a value at each index where a sign change occurs (For example, if the current element is positive and the previous element is negative and vice versa). For the array above, I would expect to get the ...

Update an sqlite database schema with sqlalchemy and elixir

I've created a python application which uses elixir/sqlalchemy to store data. The second release of the software requires any files created in the previous version to be updated in order to add/delete tables and columns. My question is: how can I achieve this? I'm aware of sqlalchemy-migrate, but I must say I find it confusing. It doesn...

Storing a list of objects in GAE

I need to store some data that looks a little like this: xyz 123 abc 456 hij 678 rer 838 Now I would just store it as a traditional string and integer model, and put in the datastore. But the data changes regularly, and is ONLY relevant when looked at as a COLLECTION. So it needs to be store as either a list of lists, or a list of ob...

fft and array-to-image / image-to-array-conversion

Hello! I want to make a fourier-transformation of an image. But how can I change the picture to an array? And after this I think I should use numpy.fft.rfft2 for the transformation. And how to change back from the array to the image? Thanks in advance. ...

Create matplotlib legend out of the figure

I added the legend this way: leg = fig.legend((l0,l1,l2,l3,l4,l5,l6), ('0 Cl : r2, slope, origin', '1 Cl :'+str(r1b)+' , '+str(m1)+' , '+str(b1), '2 Cl :'+str(r2b)+' , '+str(m2)+' , '+str(b2), '3 Cl :'+str(r3b)+' , '+str(m3)+' , '+str(b3), '4 Cl :'+str(r4b)+' , '+str(m4)+' , '+str(b4), '5 Cl :'+str(r5b)+...

Dowser: "bad argument to internal function"

Hi all! I'm trying out Dowser, it's really cool but I'm stuck with a little problem, and I couldn't find anything helpful on Google, so here I am.. ^^; I'm running a CherryPy+SQLAlchemy application.. It works normally, except that when I enable Dowser (that is, after I call dowser.Root()), now and then I get exceptions like: System...