python

Fix permissions for rpm/setuptools packaging

I have a project that requires post-install hooks for deployment. My method is to use setuptools to generate the skeleton rpm spec file and tar the source files. The problem is that I don't know how to control permissions with this method. The spec file looks like: %install python setup.py install --single-version-externally-managed ...

Deciding on a language: Python or Java

I am part of a small (read: two programmer) startup, and we are about to start developing a large (we estimate it will be about a year before customers will see anything) web application… And it's come time to pick a language. Most of the experience I have is with Python, most of my co-worker's experience is in Java and C++, but they wo...

Python on an Real-Time Operation System (RTOS)

Hello, I am planning to implement a small-scale data acquisition system on an RTOS platform. (Either on a QNX or an RT-Linux system.) As far as I know, these jobs are performed using C / C++ to get the most out of the system. However I am curious to know and want to learn some experienced people's opinions before I blindly jump into th...

Setting up/Inserting into Many-to-Many Database with Python, SQLALchemy, Sqlite

I am learning Python, and as a first project am taking Twitter RSS feeds, parsing the data, and inserting the data into a sqlite database. I have been able to successfully parse each feed entry into a content variable (e.g., "You should buy low..."), a url variable (e.g., [u'http://bit.ly/HbFwL']), and a hashtag list (e.g., #stocks', u'#...

Python - IronPython dilemma

I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them: What is the relationship between Python's C implementation (main version from python.org) and IronPython, in terms of language compatibility ? ...

Error using python doctest

I try to use doctest from example from http://docs.python.org/library/doctest.html But when I run python example.py -v I get this Traceback (most recent call last): File "example.py", line 61, in <module> doctest.testmod() AttributeError: 'module' object has no attribute 'testmod' But I can import doctest in python interacti...

"deprecated" status on Google App Engine Django

I'm looking at Google App Engine Django on google code but the latest release (May 15/09) has been deprecated. I'd like to know why that is? Are they discouraging us from using it? What deprecated it? Is there a better way to get set up with django? ...

Confused about making a CSV file into a ZIP file in django

I have a view that takes data from my site and then makes it into a zip compressed csv file. Here is my working code sans zip: def backup_to_csv(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=backup.csv' writer = csv.writer(response, dialect='excel') #code...

Combine tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet

I need to combine several tab-separated value (TSV) files into an Excel 2007 (XLSX) spreadsheet, preferably using Python. There is not much cleverness needed in combining them - just copying each TSV file onto a separate sheet in Excel will do. Of course, the data needs to be split into columns and rows same as Excel does when I manually...

Efficient way to determine whether a particular function is on the stack in Python

For debugging, it is often useful to tell if a particular function is higher up on the call stack. For example, we often only want to run debugging code when a certain function called us. One solution is to examine all of the stack entries higher up, but it this is in a function that is deep in the stack and repeatedly called, this lead...

In bash, what is the simplest way to configure lighttpd to call a local python script based on a particular URL?

In bash, what is the simplest way to configure lighttpd to call a local python script while passing any query string or name-value pairs included with the URL as a command line option for the local python app to parse? Example: www.myapp.com/sendtopython/app1.py?Foo=Bar results in the following occurring on the system. >python app1.py...

Pythonic way to return list of every n'th item in a larger list

Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...] Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line? ...

Good way to write a lightweight client function to be imported Twisted Python

Dear everyone, I have the following server running: class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): dic = simplejson.loads( line) ret = self.factory.d[ dic['method'] ]( dic['args'] ) self.transport.write( simplejson.dumps( ret) ) self.transport.loseConnection() class Thashe...

How to catch error in Django project on apache: 10048 "Address already in use"

Python 2.5.2, Apache 2.2, Django 1.0.2 final My Django app tries to connect to a certain port. When that port is busy, I get the error 10048 "Address already in use" from apache. I know where the error is coming from. How do I catch this apache error? More info: error at /report/5/2009/08/01/ (10048, 'Address already in use') Reques...

plotting in matplotlib

I have to plot 2 graphs in a single screen. x-axis remains the same but y-axis should b different. How can I do it in 'matplotlib' ? ...

Is there something like Ruby's Machinist for Python

Copied from the site http://github.com/notahat/machinist/ Machinist makes it easy to create test data within your tests. It generates data for the fields you don't care about, and constructs any necessary associated objects, leaving you to only specify the fields you do care about in your tests A simple blueprint might look like...

GVIM and multiple programming languages

My day job involves coding with Perl. At home I play around with Python and Erlang. For Perl I want to indent my code with two spaces. Where as for Python the standard is 4. Also I have some key bindings to open function declarations which I would like to use with all programming languages. How can this be achieved in GVIM? As in, is the...

Python sched.scheduler exceeds max recursion depth

Hello, I have recently started learning Python and part of the simple app I am making includes a timer with a hh:mm:ss display running in its own thread. Looking around the web I found two ways of implementing this: Using sched.scheduler Using threading.Timer The way I did it looks similar for both implementations: sched: def tic...

How to get output from external command combine with Pipe

I have command like this. wmctrl -lp | awk '/gedit/ { print $1 }' And I want its output within python script, i tried this code >>> import subprocess >>> proc = subprocess.Popen(["wmctrl -lp", "|","awk '/gedit/ {print $1}"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>> proc.stdout.readline() '0x0160001b -1 6504 ...

Socket programming

Hi everyone: Please take a look at my code: from twisted.internet.protocol import ServerFactory from twisted.internet import reactor from twisted.protocols import basic class ThasherProtocol(basic.LineReceiver): def lineReceived(self, line): print line self.transport.write( 1 ) self.transport.loseConnectio...