python

What are the best benefits of using Pinax ?

I recently discovered Pinax that appear to be an django stack with added most-used apps so easy and speed up development. I never used or heard of Pinax before and like to know if you have feedback about it. I love Django and would like to understand what are to parts of web dev Pinax helps with and using what tools. ...

Role-based security with Google App Engine and Python

Hi all, I would like to ask what is the common way for handling role-based security with Google App Engine, Python? In the app.yaml, there is the "login" section, but available values are only "admin" and "required". How do you normally handle role-based security? Create the model with two tables: Roles and UserRoles Import values f...

[Django] Custom storage system for GridFS (MongoDB)?

Can anyone point me to any projects/django apps that provide a plugable custom storage system so I can use GridFS with Django to store file uploads? I've found django-mongodb but it doesnt seem to support GridFS, nor does django-storages. Edit: I plan to run mysql for the normal database requrements and only use mongodb for file stora...

How to install MySQLdb (Python data access library to MySQL) on Mac OS X?

I'm a Python newbie, but I've just spent a day working out how to get MySQLdb working properly, and the universe according to google includes numerous references to what a PITA it is, and an inordinate number of guides that seem to be outdated. Given that this site is intended to address these sorts of problems, and I know that I'm goin...

Python - I can't stop the program running.

Hi there, I am completely new to python. I have installed it on windows. I am having a problem, I write: from pylab import* subplot(111,projection="hammer") show() After this it will not let me do anything else and ctrl-c does not work. I have looked at another post here and tried ctrl-break, ctrl-z and various other methods to no a...

Python subprocess.Popen - adding GCC flags results in "no input files" error

I'm building a Python script to automate my build process, which invokes GCC using subprocess.Popen. My initial attempt works fine. >>> import subprocess >>> p = Popen(['gcc', 'hello.c'], stdout=subprocess.PIPE, stderr=stderr=subprocess.STDOUT) >>> p.wait() 0 >>> p.communicate() ('', None) However, once I pass additional options to G...

Multiple visualizations in one page

I am using python-visualization library for computing the datasource. I tried to put more than one visualization in a single page. Both are line charts and data comes from a seperate URLs for each visualizations. <script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; <script type="text/javascript" src="/site...

How to install pysqlite?

Hi all, I am trying to install pysqlite (Python interface to the SQLite). I downloaded the file with the package (pysqlite-2.5.5.tar.gz). And I did the following: gunzip pysqlite-2.5.5.tar.gz tar xvf pysqlite-2.5.5.tar \cd pysqlite-2.5.5 python setup.py install At the last step I have a problem. I get the following error message: er...

variable length of %s with the % operator in python

I'm trying to do this: max_title_width = max([len(text) for text in columns]) for column in columns: print "%10s, blah" % column But I want to replace the 10 with the value of max_title_width. How do I do this in the most pythonic way possible? ...

subversion python bindings documentation?

Where can I find a good introduction to using the subversion python bindings? I found one section in the svnbook that talks about it; and some basic examples from 1.3. Is there something a bit more thorough and up-to-date? ...

How to install MySQLdb package? (ImportError: No module named setuptools)

Hi All, I am trying to install MySQLdb package. I found the source code here. I did the following: gunzip MySQL-python-1.2.3c1.tar.gz tar xvf MySQL-python-1.2.3c1.tar cd MySQL-python-1.2.3c1 python setup.py build As the result I got the following: Traceback (most recent call last): File "setup.py", line 5, in ? from setuptool...

Simple object recognition

===SOLVED=== Thanks for your suggestions and comments. By working on the flood_fill algorithm given in Beginning Python Visualization book (Chapter 9 - Image Processing) I have implemented what I have wanted. I can count the objects, get enclosing rectangles for each object (therefore height and widths), and lastly can construct NumPy a...

Google app engine and python and objects that pass by value

This is really a python language question, but its wrapped around a Google appengine specific problem. We have class User( db.Model ) : email = db.StringProperty() name = db.StringProperty() password = db.StringProperty() # more fields.. Because the user account is accessed so often, we keep a copy in session using gaeutili...

How to install setuptools?

I'm trying to install setuptools. When I run "sh setuptools-0.6c9-py2.4.egg" I get the following message: Permission denied: '/usr/lib/python2.4/site-packages/test-easy-install-26338.write-test' It is expectable, since I do not have root permissions on the system. Some how I came to the idea of creating a "Virtual" Python. I dow...

How do I install Python packages on Windows?

I'm having a hard time setting up python packages. EasyInstall from SetupTools is supposed to help that, but they don't have an executable for Python 2.6. For instance to install Mechanize, I'm just supposed to put the Mechanize folder in C:\Python24\Lib\site-packages according to INSTALL.txt, but runnning the tests does not work. Can s...

How to convert an NSDictionary to a Python dict?

I have a plugin written entirely in Python using PyObjC whose core classes I need to convert to Objective-C. One of them basically just loads up a Python module and executes a specific function, passing it keyword arguments. In PyObjC, this was extremely. However, I'm having difficulty figuring out how to do the same thing using the P...

PIL not rendering fonts uniformly across machines

I wrote some code that spits out an image. The code ran on my local machine yields this image: and on my webhost, it looks like this: As you can see they are different. The top is much nicer. Both are using the same code, and the same font file (VeraMoBd.ttf), the same version of PIL (1.1.6), and the same Python version (2.6). I g...

Converting 2.5 byte comparisons to 3

I'm trying to convert a 2.5 program to 3. Is there a way in python 3 to change a byte string, such as b'\x01\x02' to a python 2.5 style string, such as '\x01\x02', so that string and byte-by-byte comparisons work similarly to 2.5? I'm reading the string from a binary file. I have a 2.5 program that reads bytes from a file, then compare...

Python TurtleGraphics - Making a randomly moving turtle?

I'm trying to create a randomly moving turtle here by following these steps in a function I've called drunk_turtle(): Repeat the following as many times as you like: Randomly choose an integer, called rand_num, from -1 to 1 (i.e. randomly set rand_num to be -1, 0, or 1) Make the turtle turn right rand_num * 90 degrees; Go forward 5, 1...

Getting SVN revision number into a program automatically

I have a python project under SVN, and I'm wanting to display the version number when it is run. Is there any way of doing this (such as automatically running a short script on commit which could update a version file, or querying an SVN repository in Python?) ...