python

Is there a way to package a python extension written in C into a binary so I don't have to python-install it?

I wrote a Python extension in C, and my python program uses that extension. In order for it to work, I would have to install the extension on the user's system before my program can run. Is there a way to bypass that installation step and somehow just have the extension in my python package? The only compiled part obviously is the extens...

globals aren't working

>>> t('$x')() Traceback (most recent call last): ... NameError: global name 'x' is not defined >>> t('$x', globals={'x': 1})() I expected: u'1\n' the actual was: Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 't' is not defined Why aren't my globals working? ...

Python packaging-installation-virtualenv question

With Python 2.4 on Centos, when I create an RPM with setuptools (bdist_rpm), add it to my yum repository and install it with yum, the top-level Python packages are extracted and put directly in site-packages, along with a .egg-info directory for the full package. So, e.g., if spam-1.2.3 has a top-level package called "spam", then packag...

Modeling Hierarchical Data - GAE

Hi, I'm new in google-app-engine and google datastore (bigtable) and I've some doubts in order of which could be the best approach to design the required data model. I need to create a hierarchy model, something like a product catalog, each domain has some subdomains in deep. For the moment the structure for the products changes less t...

Who stops my threads?

I have some threads fishing into a queue for jobs, something like this: class Worker(Thread): [...] def run(self): while not self.terminated: job = myQueue.get_nowait() job.dosomething() sleep(0.5) Now, self.terminated is just a bool value I use to exit the loop but, this is the prob...

Python/Django AttributeError "Object 'players' has no attribute 'fields'

I am setting up the admin page so that I might be able to use it to add data, players in this case. When you go and attempt to register the Players class in admin.py you get the error described in the question title (object 'players' has no attribute 'fields'). Looking through views.py that I pasted a snippet out of below I don't see wha...

Tagging similar sentences with lower time complexity than n^2

Hey All This is my first post, have been a lurker for a long time, so will try my best to explain myself here. I have been using lowest common substring method along with basic word match and substring match(regexp) for clustering similar stories on the net. But the problem is its time complexity is n^2 (I compare each title to all the...

Accessing the content of a variable array with ctypes.

Hi there, I use ctypes to access a file reading C function in python. As the read data is huge and unknown in size I use **float in C . int read_file(const char *file,int *n_,int *m_,float **data_) {...} The functions mallocs an 2d array, called data, of the appropriate size, here n and m, and copies the values to the referenced ones...

Steps for how to install QT, PyQT, and PySide on OS X Snow Leopard

I've had some problems installing QT on Snow Leopard and I'm hoping that I can benefit from someone else who's been in this position. :) I'm assuming that I'll need to use a version of python that's not included with SL... be it from homebrew, macports, python.org, etc. Can anyone give me some simple steps to follow to get QT, PyQT, an...

How do you generate the non-convex hull from a series of points?

I am currently trying to construct the area covered by a device over an operating period. The first step in this process appears to be constructing a polygon of the covered area. Since the pattern is not a standard shape, convex hulls overstate the covered area by jumping to the largest coverage area possible. I have found a paper th...

Cannot find MacOS.so

Hi I'm trying to use a Python library which apparently must load code from MacOS.so, but it cannot be found on my system. I've tried linking to other ones found with the locate command, but with complaints about flat namespace. I'm wondering if it's required then why is it not packaged with other libraries? Where can I find the source f...

how to deal with .mdb access files with python

Hello all, Can someone point me in the right direction on how to open a .mdb file in python? I normally like including some code to start off a discussion, but I don't know where to start. I work with mysql a fair bit with python. I was wondering if there is a way to work with .mdb files in a similar way? ...

Measuring elapsed time with the Time module

With the Time module in python is it possible to measure elapsed time? If so, how do I do that? I need to do this so that if the cursor has been in a widget for a certain duration an event happens. ...

python: getting the last char in a string

i have a list: row=['hi', 'there', 'how', ...........'some stuff is here are ','you'] as you can see row[8]='some stuff is here are ' if the last character is a space i would like to get everything except for the last character like this: if row[8][len(row[8])-1]==' ': row[8]=row[8][0:len(row[8])-2] this method is not working. c...

Appengine - Reportlab PDF

Hello, I'm using Google appengine and want to generate a PDF with reportlab. The application works well and can generate PDF's like 'Hello World' and little else. But what I want is to fetch data from a form with the data that the user entered and generate PDF dynamically. Anyone can share a piece of code? I would be grateful. ...

Is there a way to write a command so that it aborts a running function call?

I have a widget that measures elapsed time, then after a certain duration it does a command. However, if the widget is left I want I want it to abort this function call and not do the command. How do I go about this? ...

python: cleaning up a string

i have a string like this somestring='in this/ string / i have many. interesting.occurrences of {different chars} that need to .be removed ' here is the result i want: somestring='in this string i have many interesting occurrences of different chars that need to be removed' i started to manually do all kinds of .replace, but t...

How to deal with Python ~ static typing?

I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone? ...

Using Twill from Python to open a link: " 'module' object has no attribute 'Popen' " What is it?

Hello!!! I have downloaded and installed Python 2.5.4 on my computer (my OS is Windows XP), downloaded “Goggle App Engine Software Development Kit” and created my first application in Python, which was a directory named helloworld that contained a small python file with the same name (helloworld.py). Here are the contents of that small ...

Get list of changesets in a changegroup (mercurial python hook)

I want a mercurial hook that will run JSLint/PyChecker/etc on all files that are modified. However, I do not have control over all hg clients, and want this to run on push to the master repository (which I have control), so a pretxnchangegroup hook on the master seems best. How can I get a list of all changesets that are in the changegr...