python

Combine matrix in numpy

Suppose I have three "sheets" of matrix a,b and c, each with the same m*n*p dimension. And I want to combine them to get a new m*n*p*3 matrix whose (i,j,k) element is (a[i,j,k],b[i,j,k],c[i,j,k]). Which command should I use ? The dstack command seems not work here. Thanks. ...

Xpath builder in Python

I'm building relatively complicated xpath expressions in Python, in order to pass them to selenium. However, its pretty easy to make a mistake, so I'm looking for a library that allows me to build the expressions without messing about with strings. For example, instead of writing locator='//ul[@class="comment-contents"][contains(., "Wes...

numpy to matlab interface with mlabwrap

I am looking for a simple way to visualize some of my data in numpy, and I discovered the mlabwrap package which looks really promising. I am trying to create a simple plot with the ability to be updated as the data changes. Here is the matlab code that I am trying to duplicate >> h = plot([1,2,3], [1,2,3], '-o'); >> set(h, 'XData', [...

Python, Threads, the GIL, and C++

Is there some way to make boost::python control the Python GIL for every interaction with python? I am writing a project with boost::python. I am trying to write a C++ wrapper for an external library, and control the C++ library with python scripts. I cannot change the external library, only my wrapper program. (I am writing a functi...

Displaying graphics on top of another full screen application; hardware overlay?

On Windows (Vista32), I want to display some simple graphics on top of a fullscreen flash window (an overlay of useful information while using the flash application). What's the fastest way to accomplish it? I think I may be able to achieve it using DirectX with the DDSCAPS_OVERLAY flag but with the only example I've found I get an exce...

Why use Django on Google App Engine?

When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the v...

__del__ method being called in python when it is not expected

Hello, I am new to python and have been working through the examples in Swaroop CH's "A Byte of Python". I am seeing some behavior with the __del__ method that is puzzling me. Basically, if I run the following script (in Python 2.6.2) class Person4: '''Represents a person''' population = 0 def __init__(self, name): ...

how do I add a python module on MacOS X?

I'm trying to use pywn, a python library for using WordNet. I've played about with python a little under Windows, but am completely new at MacOS X stuff. I'm running under MacOS 10.5.8, so my default Python interpreter is 2.5.1 The pywn instructions say: "Put each of the .py files somewhere in your python search path." Where is the pyt...

How to extract the first hit elements from an XML NCBI BLAST file?

Hello all, Im trying to extract only the first hit from an NCBI xml BLAST file. next I would like to get only the first HSP. at the final stage I would like to get these based on best score. to make things clear here a sample of the xml file: <?xml version="1.0"?> <!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "http://www.n...

create.event array expected error

Hi, I am trying to create a Facebook event using RESTful API Events.create method with the following parameters: event_info = {"name":event_name, "category":event_category, "subcategory":event_subcategory, "host":event_host, "city":event_city, "location":event_locati...

File searching: TypeError

Hi there, Im trying to search a file where the the line containing the search term is found and printed along with a number of lines before and after the search term defined by the user. The coding i have so far is: f = open(f, 'r') d = {} for n, line in enumerate(f): d[n%numb] = line.rstrip() if search_term in line: fo...

pyfacebook and javascript query

Hi, I'm using pyfacebook on the backend and javascript on the client side. Now if I want to pass a variable to the javascript from pyfacebook. how would I go about doing that, any ideas? ...

Python send cmd on socket.

Hi I have a simple question about Python: I have another Python script listening on a port on a Linux machine. I have made it so I can send a request to it, and it will inform another system that it is alive and listening. My problem is that I don't know how to send this request from another python script running on the same machine (...

Excluding last element in 0-based indexing

Once when I was reading some python docs I came across a reference to an article that explained why programming languages with 0-based indexing should always exclude the last element during operations like slicing: >> a = [1, 2, 3] >> a[0:1] [1] #and not [1,2] Unfortunately I did not bookmark it. Does anyone know which article I am t...

wxPython - DatePickerCtrl seems to ignore SetValue()

I'm trying to pre-populate a wxPython DatePicker with a value using the following code: month, day, year = runData[2][0:8].split('/') displayDate = wx.DateTimeFromDMY(int(day), int(month) - 1, int(year)) self.datePicker.SetValue(displayDate) Here are the printed values: runData[2] = 12/16/09 00:00 month, day, year = 12 16 09 display...

Can I do Django & Python web development using Xcode 3.2?

I'm not sure but I believe that Python is -next to Objective-C- somewhat natural to Mac OSX and the Xcode IDE. I might be wrong. So is it a good idea to use Xcode for Django / Python web development when I'm already a bit familiar with Xcode? Actually I only do iPhone dev with it, but now I need a website and I stumbled over Django / Pyt...

What are the major differences between Python and PHP?

I know PHP a little. But Python is totally new for me. I only know it's something "similar", right? Or wrong? What are the differences I should know? ...

Are there good Tutorials on how to make web apps with Python?

I think I'm gonna start learning Python web development from scratch. So if someone knows good tutorials on this, please post links. ...

operator overloading in python

Possible Duplicates: Python: defining my own operators? Rules of thumb for when to use operator overloading in python hi.. can i overload operators in python? if so, can i define new operators like << or ++? thanks in advance.. ...

Is it true that I can't use curly braces in Python?

I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like that all appear without surrounding their block with curly braces? ...