python

stopping a cherrypy server over http

I have a cherrypy app that I'm controlling over http with a wxpython ui. I want to kill the server when the ui closes, but I don't know how to do that. Right now I'm just doing a sys.exit() on the window close event but thats resulting in Traceback (most recent call last): File "ui.py", line 67, in exitevent urllib.urlopen("http:...

Python and Rpy2: Calling plot function with options that have "." in them

I'm just starting to learn how to use rpy2 with python. I'm able to make simple plots and such, but I've run into the problem that many options in R use ".". For example, here's an R call that works: barplot(t, col=heat.colors(2), names.arg=c("pwn", "pwn2")) where t is a matrix. I want to use the same call in python, but it reje...

How to play sound in Python WITHOUT interrupting music/other sounds from playing

I'm working on a timer in python which sounds a chime when the waiting time is over. I use the following code: from wave import open as wave_open from ossaudiodev import open as oss_open def _play_chime(): """ Play a sound file once. """ sound_file = wave_open('chime.wav','rb') (nc,sw,fr,nf,comptype, compname) = so...

What are the advantages of using Django insead of app-engine's default web framework?

I'm building my first python app on app-engine and wondering if I should use Django or not. What are the strong points of each? If you have references that support your answer, please post them. Maybe we can make a wiki out of this question. ...

How to suppress console output in Python?

I'm using Pygame/SDL's joystick module to get input from a gamepad. Every time I call its get_hat() method it prints to the console. This is problematic since I use the console to help me debug and now it gets flooded with SDL_JoystickGetHat value:0: 60 times every second. Is there a way I can disable this? Either through an option in Py...

how does change 'username-password login' to 'email-password login' on django-registration

i want a example. thanks ...

How to properly escape output (for XHTML) in mako?

Despite offering a nice way to escape output using filters, none of them do the right thing. Taking the string: x=u"&\u0092" The filters do the following: x Turns the & into an entity but not the \u0092 (valid XML but not XHTML) h Exactly the same u Escapes both, but obviously uses url escaping ent...

After breaking a python program into functions, how do I make one the main function?

This is the biggest newbie question on the planet, but I'm just not sure. I've written a bunch of functions that perform some task, and I want a "main" function that will, for example, when I call "someProgram.py", run function1, function2 and quit. I vaguely remember something about "main" but I have no clue. ...

How limiting are web frameworks

Hi, This is a general question about how limiting are web development frameworks such as Django and ruby-on-rails. I am planning on building a RESTful web service which will have a purely JSON/XML interface, no GUI. The service will rely on a database however for a few of the more important operations there is no clear way of persistin...

How to organize an app-engine application

I want to create a directory structure like the following. How can I get the account.py and game.py to handle the requests that go to \account\ and \game\ respectfully. All the app-engine examples I have seen have all the logic in on main.py that handle all urls. app\account\ \account.py \game\ \ game.py \st...

Which python installation should I use?

I'm about to refresh myself in programming and I have decided on Python 2.6 for that. I have searched the net and it gave me two possible installers for download. One is from the Python site and another is from Activestate. Which one should I install on my Windows computer? ...

Python os.path is ntpath, how?

Can someone tell me how Python "aliases" os.path to ntpath? >>> import os.path >>> os.path <module 'ntpath' from 'C:\Python26\lib\ntpath.pyc'> >>> ...

Machine learning issue for negative instances

Hello. I had to build a concept analyzer for computer science field and I used for this machine learning, the orange library for Python. I have the examples of concepts, where the features are lemma and part of speech, like algorithm|NN|concept. The problem is that any other word, that in fact is not a concept, is classified as a concept...

Using Django's Model API without having to *include* the full Django stack

Currently an application of mine is using SQLAlchemy, but I have been considering the possibility of using Django model API. Django 1.1.1 is about 3.6 megabytes in size, whereas SQLAlchemy is about 400 kilobytes (as reported by PyPM - which is essentially the size of the files installed by python setup.py install). I would like to use...

An equivalent to string.ascii_letters for unicode strings in python 2.x?

In the "string" module of the standard library, string.ascii_letters ## Same as string.ascii_lowercase + string.ascii_uppercase is 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' Is there a similar constant which would include everything that is considered a letter in unicode? ...

Processing a simple workflow in Python

I am working on a code which takes a dataset and runs some algorithms on it. User uploads a dataset, and then selects which algorithms will be run on this dataset and creates a workflow like this: workflow = {0: {'dataset': 'some dataset'}, 1: {'algorithm1': "parameters"}, 2: {'algorithm2': "parameters"}, 3: {'algorithm3': "paramet...

web2py - my application doesn' login

i have a web2py application and am using default/user/login to login to my application but sometimes when i login the application redirect to the login page agin and sometimes the system logged fine and there is no problem i dont know why ? so please can anyone tell me ? Thanks in advance ...

Can you really scale up with Django...given that you can only use one database? (In the models.py and settings.py)

Django only allows you to use one database in settings.py. Does that prevent you from scaling up? (millions of users) ...

Any Python alternatives to Selenium for programmatically logging into websites that require JavaScript for login?

I’m writing a little private app to automatically log into my internet banking every day, and download the latest transactions. I’m writing it as a Django app, so I’m working in Python. My internet banking doesn’t seem to work without JavaScript — I think it uses JavaScript to assign a session ID of some sort. Fetching the sign-in page ...

Matplotlib with dual scale mouse over

Hello all, I try to plot some curves with matplotlib using the default gui component and have some trouble to select which of the two y-axes that the mouse over functionality should select. The default case seems to be that ax2 gets selected but I would like to use ax1 instead. Is this possible to fix in some easy way? This is the cod...