python

Alternative to pygobject?

Hi, does anyone have an alternative to using pygobject as i can't seem to get this to run at all in Mac OS X. I'm trying to use papyon which fails amazingly well if gobject isn't around. Joe ...

Python CGI transaction

I have a Python CGI handling a payment transaction. When the user submits the form, the CGI is called. After submission, the CGI takes a while to perform the credit card transaction. During that time, a user might hit the ESC or refresh button. Doing that will not "kill" the CGI, meaning, the script will keep running completing the trans...

How to debug Jinja2 template ?

I am using jinja2 template system into django. It is really fast and I like it a lot. Nevertheless, I have some problem to debug templates : If I make some errors into a template (bad tag, bad filtername, bad end of block...), I do not have at all information about this error. For example, In a django view, I write this : from jinja2 i...

How can I add an additional row and column to an array?

hello all, I need to add a column and and a row to an existing numpy array at a position defined as I can. forgiveness for my regular English. and thanks for any response ...

Why does Django admin try to encode strings into ASCII rather than Unicode? Or is this error something different than it looks like?

I've got the following error: TemplateSyntaxError at /admin/results_cop/copsegmentresult/ Caught an exception while rendering: ('ascii', 'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96', 98, 99, 'ordinal not in range(128)') The fragment of the s...

Apps won't show in Django admin

I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine. My apps are in settings.py I have admin.autodiscover in my root urls.py file from django.conf.urls.defaults import * from django.conf import settings from django.views.generic.simple import direct_to_templ...

GQL with two tables

Hello i am doing a very small application in google appengine and i use python. My problem is that i have two tables using de db.model ("clients" and "requests"). The table "client" has got the email and name fields and the table "requests" has got the email and issue fields. I want to do a query that returns for each request the email, ...

how can i use '__set__'.

class A(object): def __get__(self, instance, owner):#why i can't find argument 'key',where is 'key' #print ower.instance print instance,owner def __set__(self,instance,value): instance=value class X(object): a = A() xx=X() xx.a='aaa' print xx.a#None thanks ...

How to force Python to ignore re.DOTALL in re.findall() statement?

I have been banging my head against the keyboard in search of enlightenment through Google and all Python docs I could get my hands on, but could not find an answer to an issue I'm encountering. I have the following regex that I run against a website, but Python insists in setting re.DOTALL on it, even though my code does not tell it to...

How to use Python tkSimpleDialog.askstring

I want to use the response from an askstring prompt to set a variable. Unfortunately, I have the dilemma that I'm trapped in the loop asking the question or the window refuses to draw because the variable (urltoopen) has no value. The code as it stands: urltoopen = tkSimpleDialog.askstring('Address', 'Where do we get the pictures from?...

Why are django projects python packages?

Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the __init__.py at all? The project is perfectly useful without it. What is the justification? ...

AppEngine/Python, query database and send multiple images to the client as a response to a single get request.

I am working on a social-network type of application on App Engine, and would like to send multiple images to the client based on a single get request. In particular, when a client loads a page, they should see all images that are associated with their account. I am using python on the server side, and would like to use Javascript/JQue...

Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other)

Looking for advice on the best technique for saving complex Python data structures across program sessions. Here's a list of techniques I've come up with so far: pickle/cpickle json jsonpickle xml database (like SQLite) Pickle is the easiest and fastest technique, but my understanding is that there is no guarantee that pickle output...

google app engine jsonpickle

Has anyone got jsonpickle working on the google app engine? My logs say there is no module but there is a module as sure as you're born. i'm using jsonpickle 0.32. <type 'exceptions.ImportError'>: No module named jsonpickle Traceback (most recent call last): File "/base/data/home/apps/xxxxx/xxxxxxxxxxxxxxxxx/main.py", line 4, in <modu...

How can I get the current week using Python?

Using Python... How can I get a list of the days in a specific week? Something like... { '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/2010'] } The key of the dictionary in this example...

where is the '__path__' comes from.

i can't find who defined the '__path__',why '__path__' can be use. import os import sys import warnings import ConfigParser # ConfigParser is not a virtualenv module, so we can use it to find the stdlib dirname = os.path.dirname distutils_path = os.path.join(os.path.dirname(ConfigParser.__file__), 'distutils') if os.path.normpath(di...

Python ftplib: Overwriting a File doesn't work with STOR

I want to overwrite an existing file "test.txt" on my ftp server with this code: from ftplib import FTP HOST = 'host.com' FTP_NAME = 'username' FTP_PASS = 'password' ftp = FTP(HOST) ftp.login(FTP_NAME, FTP_PASS) file = open('test.txt', 'r') ftp.storlines('STOR test.txt', file) ftp.quit() file.close() I don't get any error messages a...

How can I select all of the Sundays for a year using Python?

Using Python... How can I select all of the Sundays (or any day for that matter) in a year? [ '01/03/2010','01/10/2010','01/17/2010','01/24/2010', ...] These dates represent the Sundays for 2010. This could also apply to any day of the week I suppose. ...

PyQt4 Signalling between classes

Hi folks, I have a family of classes (based on the same parent class) that are data cells in a QTableWidget (so they are all derived from QItemDelegate). I'm trying to create a signal that these classes can pass up to the controller to communicate data changes. I can't find the right combination (despite much experimentation and rea...

UnicodeEncodeError on joining file name

It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code: filename = 'Spywaj.ttf' print repr(filename) >> 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) But the file is valid and existed on disk. Filename was extracted from "unzi...