python

Selecting distinct column values in SQLAlchemy/Elixir

In a little script I'm writing using SQLAlchemy and Elixir, I need to get all the distinct values for a particular column. In ordinary SQL it'd be a simple matter of SELECT DISTINCT `column` FROM `table`; and I know I could just run that query "manually," but I'd rather stick to the SQLAlchemy declarative syntax (and/or Elixir) if I c...

Problem deploying Django-Mingus with Flup and Cherokee. Strange admin behaviour.

I have a django-mingus blog running perfectly fine with the integrated development web server of django. It's installed in a virtualenv. Once deployed using the django app wizard of cherokee 0.99.42 the admin pannel is displaying a strange behaviour. Sometimes all apps are displayed in the admin pannel sometime only a subset of the apps...

Implementing chat system with in Web browser

We want to have web based application to track the issues, knowledge management and chat system. Once the user logged in, user can chat with the service engineers. We will be using Ajax for Chat within the browser. But the server-side we are not sure how to implement chat? The chat history must be saved for lateral viewing. When someone...

What are the downsides of using Python instead of Objective-C?

I know some Python and I'm really impressed by the language's ease of use. From what I've seen of Objective-C it looks a lot less pretty, but it seems to be the lingua franca for Mac OS X development (which means it has better documentation). I'm thinking about starting Mac development - will using PyObjC+Python make me a second class ...

PostgreSQL problem in Django

I have a Django application and I'm using postgres. I try to execute the bollowing line in one of my tests: print BillingUser.objects.all() And I get the following error: "current transaction is aborted, commands ignored until end of transaction block." My postresql log: ERROR: duplicate key value violates unique constraint "...

mercurial - I want to add some custom code to be run after commit

Hi - where could I place code to be run after every commit I make with mercurial? Specifically, I would like to maintain a file called latest inside the .hg folder in the root of my project - that file will hold the revision number and hash code for the most recent commit. On that same topic, how can I get those in python? # get mercu...

can we execute mutiple python scripts from same interpreter

Hi, I have a python script, which is executing again 4-5 python scripts. For performance reasons i want to use same interpreter for executing all the script. Is it Possible to do that, if yes please help me out. Thanks Kamal ...

Django admin authentication failure

Hi folks, logging into django admin fails when 'log in' button is pressed first time, but pressing "back" and "log in' again - logs the user in successfully. I am deploying Django app with zc.buildout here, with a setup similar to what is described here http://www.meppum.com/2009/jan/17/installing-django-ubuntu-intrepid/. Nginx (listen...

Can Django ORM do an ORDER BY on a specific value of a column?

I have a table 'tickets' with the following columns id - primary key - auto increment title - varchar(256) status - smallint(6) - Can have any value between 1 and 5, handled by Django When I'll do a SELECT * I want the rows with status = 4 at the top, the other records will follow them. It can be achieved by the following query: sel...

Hiding axis text in matplotlib plots

Hi All, I'm trying to plot a figure without tickmarks or numbers on either of the axes (I use axes in the traditional sense, not the matplotlib nomenclature!). An issue I have come across is where (for example) matplotlib adjusts the x(y)ticklabels by subtracting a value N, then adds N at the end of the axis. This may be vague, but the...

How do I convert a string to a buffer in Python 3.1?

I am attempting to pipe something to a subprocess using the following line: p.communicate("insert into egg values ('egg');"); TypeError: must be bytes or buffer, not str How can I convert the string to a buffer? ...

Which is the best python library to make REST request like PUT, GET, DELETE, POST and how ?

Hi, I am bit confuse over set of libraries of pythons to connect with REST enabled web services. I have tried httplib, urllib and urllib2. I want to know how can methods like PUT, GET, POST, DELETE can be achieved using this library. Regards, Parthiv ...

Filter files in a very large folder

I have a folder with 100k text files. I want to put files with over 20 lines in another folder. How do I do this in python? I used os.listdir, but of course, there isn't enough memory for even loading the filenames into memory. Is there a way to get maybe 100 filenames at a time? Here's my code: import os import shutil dir = '/somedir...

RoR or Python for new development work?

I have spent the last month investigating and learning RoR and Python. I have been developing with PHP for the last few years, but the time has come to move on. To be honest I like both RoR as well as Python and currently leaning more towards RoR. My question is which language do you think is going to have more impact on the web over t...

Individually labeled bars for bar graphs in matplotlib / Python

I am trying to create bar graphs of letter frequency in Python. I thought the best way to accomplish this would be matplotlib, but I have been unable to decipher the documentation. Is it possible to label the bars of a matplotlib.pyplot.hist plot with one letter per bar, instead of a numerical axis? I think it must be, but I have not use...

How can I reorder a list in python?

If I have a list [a,b,c,d,e] how can I reorder the items in an arbitrary manner like [d,c,a,b,e]? Edit: I don't want to shuffle them. I want to re-order them in a predefined manner. (for example, I know that the 3rd element in the old list should become the first element in the new list) ...

How to actually build 64-bit Python on OS X 10.6.2

Why? I want to do this because installation of SciPy recommends it, and I thought it would be a good learning experience. This question has been asked before (e.g. here). The preferred answer seems to be to use MacPorts, but as I say, I'd like to understand how it's done. Anyway, I grab the source (Python-2.6.4.tgz) and unzip. I rea...

Python: How do I disallow imports of a class from a module?

I tried: __all__ = ['SpamPublicClass'] But, of course that's just for: from spammodule import * Is there a way to block importing of a class. I'm worried about confusion on the API level of my code that somebody will write: from spammodule import SimilarSpamClass and it'll cause debugging mayhem. ...

How can I step into pdb to diagnose this error on a production server? ProgrammingError(1110, "Column 'about' specified twice"

ProgrammingError(1110, "Column 'about' specified twice" /usr/local/lib/python2.5/site-packages/MySQLdb/connections.py errorclass <class '_mysql_exceptions.ProgrammingError'> errorvalue ProgrammingError(1110, "Column 'about' specified twice") This error seems to be happening here in django_authopenid/views.py: if 'bnewa...

Drawing anti-aliased lines in wx?

I've got a program that draws my mouse movements on a window. The only problem is the line is very rough, and i would like it (not where two different lines link, but the actual line) to be anti-aliased and to fall-off nicely. Is there a way to do that? ...