python

Why is Django reverse() failing with unicode?

Here is a django models file that is not working as I would expect. I would expect the to_url method to do the reverse lookup in the urls.py file, and get a url that would correspond to calling that view with arguments supplied by the Arguments model. from django.db import models class Element(models.Model): viewname = models.CharFi...

how to read specific number of floats from file in python?

I am reading a text file from the web. The file starts with some header lines containing the number of data points, followed the actual vertices (3 coordinates each). The file looks like: # comment HEADER TEXT POINTS 6 float 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 POLYGONS the line starting with the wor...

Get coords of an oval in Tkinter

I can't seem to figure out how to reterive the x,y position of an oval created on a Tkinter canvas using Python via c.create_oval(x0, y0, x1, y2) I understand that Tkinter creates the oval inside the box specified by x0,y0,x1,y2 and if I can get those coordinates that would also work. I need the coordinates to move the oval by an off...

Keep PyGTK Button from Resizing on Label Change

I'm working on a PyGTK app with some Buttons that, when clicked, give a text entry dialog, then set the text on the button to whatever was entered in the box. The problem is that if the text is longer than the button can show, the button changes size to accomodate. How do I keep GTK Buttons from resizing when the text changes? ...

Python XLWT attempt to overwrite cell workaround

Hi, Using the python module xlwt, writing to the same cell twice throws an error: Message File Name Line Position Traceback <module> S:\******** write C:\Python26\lib\site-packages\xlwt\Worksheet.py 1003 write C:\Python26\lib\site-packages\xlwt\Row.py 231 insert_cell C:\Py...

Using Python and Mechanize with ASP Forms

I'm trying to submit a form on an .asp page but Mechanize does not recognize the name of the control. The form code is: <form id="form1" name="frmSearchQuick" method="post"> .... <input type="button" name="btSearchTop" value="SEARCH" class="buttonctl" onClick="uf_Browse('dledir_search_quick.asp');" > My code is as follows: br = mech...

Best full-text search for google-app-engine..

did you know the best full-text search on gae ? thanks ...

Tying PyQt4 QAction triggered() to local class callable doesn't seem to work. How to debug this?

I create this object when I want to create a QAction. I then add this QAction to a menu: class ActionObject(object): def __init__(self, owner, command): action = QtGui.QAction(command.name, owner) self.action = action self.command = command action.setShortcut(command.shortcut) action.setStatusTip(command.name) ...

exceptions with python unicode encode/decode functions (why doesn't errors=ignore actually ignore them??)

Does anyone know why the string conversion functions throw exceptions when errors="ignore" is passed? How can I convert from regular Python string objects to unicode without errors being thrown? Thanks very much! python -c "import codecs; codecs.open('tmp', 'wb', encoding='utf8', errors='ignore').write('кошка')" returns Traceback (mos...

Serializing Python bytestrings to JSON, preserving ordinal character values

I have some binary data produced as base-256 bytestrings in Python (2.x). I need to read these into JavaScript, preserving the ordinal value of each byte (char) in the string. If you'll allow me to mix languages, I want to encode a string s in Python such that ord(s[i]) == s.charCodeAt(i) after I've read it back into JavaScript. The c...

Using Python as a CGI script without the CGI module?

Is it possible to use Python as CGI without using the CGI module and still get access to all of the browser information and everything? I tried: #!/usr/bin/python import sys print "Content-type: text/html" print data = sys.stdin.readlines() print len(data) but it always prints 0. ...

Case insensitive string columns in SQLAlchemy?

can i create a case insensitive string column in sqlalchemy? im using sqlite, and theres probaby a way to do it through DB by changing collation, but i want to keep it in sqlalchemy/python. ...

How to log in to a website using installed twill?

Hello, everybody!!!! I have just successfully installed TWILL on my computer with the help of one very supportive member of "StackOverflow" (you can check it out HERE) and have tried to run one of the simple examples on the twill documentation page (you can see that page HERE). Here is that example: Let's say my username on www.slash...

how to write or create (when no exist) a file using python and Google AppEngine

this is my code: f = open('text/a.log', 'wb') f.write('hahaha') f.close() and it is not create a new file when not exist how to do this , thanks updated class MyThread(threading.Thread): def run(self): f = open('a.log', 'w') f.write('hahaha') f.close() error is : Traceback (most recent call last): ...

Django multiple generic_inline_formset in a view

We have a bunch of formsets: EmailAddressInlineFormSet = generic_inlineformset_factory( EmailAddress, extra=1, exclude=["created_by","last_modified_by"]) emailaddressformset = EmailAddressInlineFormSet( instance=person, prefix="emailaddress") # [ more definitions ] and, in the view, we process them as: emailaddressfo...

In django changing the file name of uploading file.

Hi Is it possible to change the file name of the uploading file in the django? I searched, but couldn't find any answer. My requirement is whenever a file is uploaded its file name should be changed in the following format. format = userid + transaction_uuid + file_extension Thank yo very much... ...

maya2008 win32api 64 bit python

How is it possible to run import win32api successfully on a 64bit maya version 2008? The following error occurs: Error: No module named win32api Traceback (most recent call last): File "", line 1, in ImportError: No module named win32api I need to get mouse cursor position in python so that I can place window exactly in that posi...

Match language code with countries where this language is an official or commonly used language

Is there any python library to get a list of countries for a specific language code where it is an official or commonly used language? For example, language code of "fr" is associated with 29 countries where French is an official language plus 8 countries where it's commonly used. ...

Python Django Global Variables

Hi all, I'm looking for simple but recommended way in Django to store a variable in memory only. When Apache restarts or the Django development server restarts, the variable is reset back to 0. More specifically, I want to count how many times a particular action takes place on each model instance (database record), but for performan...

Python vs Ruby Top Sites

Hi, I was just trying to find some comparison of the existing python web frameworks and ruby frameworks. There are few promising frameworks in python but I was not able to find a top 100 site using python except for google, which uses python extensively. Python has great frameworks but I am not able to find a really popular sites usin...